bulk comment fixes
[civicrm-core.git] / CRM / Core / QuickForm / Action / Display.php
index 832b617d7977db4d1e8dc4c3de290d0b092571d5..0501b2c19c2fb75e436bdf4060223c8b329332a9 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -29,7 +29,7 @@
  * Redefine the display action.
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -52,8 +52,8 @@ class CRM_Core_QuickForm_Action_Display extends CRM_Core_QuickForm_Action {
    *
    * @param object $stateMachine reference to state machine object
    *
-   * @return object
-   * @access public
+   * @return \CRM_Core_QuickForm_Action_Display
+  @access public
    */
   function __construct(&$stateMachine) {
     parent::__construct($stateMachine);
@@ -104,8 +104,9 @@ class CRM_Core_QuickForm_Action_Display extends CRM_Core_QuickForm_Action {
    * render the page using a custom templating
    * system
    *
-   * @param object  $page the CRM_Core_Form page
-   * @param boolean $ret  should we echo or return output
+   * @param object $page the CRM_Core_Form page
+   *
+   * @internal param bool $ret should we echo or return output
    *
    * @return void
    * @access public
@@ -126,7 +127,8 @@ class CRM_Core_QuickForm_Action_Display extends CRM_Core_QuickForm_Action {
     $template->assign('isForm', 1);
 
     $controller = &$page->controller;
-    if ($controller->getEmbedded()) {
+    // Stop here if we are in embedded mode. Exception: displaying form errors via ajax
+    if ($controller->getEmbedded() && !(!empty($form['errors']) && $controller->_QFResponseType == 'json')) {
       return;
     }
 
@@ -157,9 +159,10 @@ class CRM_Core_QuickForm_Action_Display extends CRM_Core_QuickForm_Action {
     }
 
     if ($controller->_QFResponseType == 'json') {
-      $response = array(
-        'content' => $html,
-      );
+      $response = array('content' => $html);
+      if (!empty($page->ajaxResponse)) {
+        $response += $page->ajaxResponse;
+      }
       if (!empty($form['errors'])) {
         $response['status'] = 'form_error';
         $response['errors'] = $form['errors'];