X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FForm.php;h=f26ce82e2454c8c57c75b9bdeccf001fcd214b4c;hb=20f57460897100cb2aea105c40c16ab16604033a;hp=55a36e4ade2705f3a00311e0f67aeebbe894a636;hpb=fffe9ee184e24329ff99969ec36fbfbde2016c09;p=civicrm-core.git diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 55a36e4ade..f26ce82e24 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -37,6 +37,10 @@ */ require_once 'HTML/QuickForm/Page.php'; + +/** + * Class CRM_Core_Form + */ class CRM_Core_Form extends HTML_QuickForm_Page { /** @@ -292,13 +296,15 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * This function is just a wrapper, so that we can call all the hook functions + * @param bool $allowAjax - FIXME: This feels kind of hackish, ideally we would take the json-related code from this function + * and bury it deeper down in the controller */ - function mainProcess() { + function mainProcess($allowAjax = TRUE) { $this->postProcess(); $this->postProcessHook(); // Respond with JSON if in AJAX context (also support legacy value '6') - if (!empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], array(CRM_Core_Smarty::PRINT_JSON, 6))) { + if ($allowAjax && !empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], array(CRM_Core_Smarty::PRINT_JSON, 6))) { $this->ajaxResponse['buttonName'] = str_replace('_qf_' . $this->getAttribute('id') . '_', '', $this->controller->getButtonName()); $this->ajaxResponse['action'] = $this->_action; if (isset($this->_id) || isset($this->id)) { @@ -812,6 +818,16 @@ class CRM_Core_Form extends HTML_QuickForm_Page { return self::$_template->get_template_vars($name); } + /** + * @param $name + * @param $title + * @param $values + * @param array $attributes + * @param null $separator + * @param bool $required + * + * @return HTML_QuickForm_group + */ function &addRadio($name, $title, $values, $attributes = array(), $separator = NULL, $required = FALSE) { $options = array(); $attributes = $attributes ? $attributes : array(); @@ -831,6 +847,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page { return $group; } + /** + * @param $id + * @param $title + * @param bool $allowClear + * @param null $required + * @param array $attributes + */ function addYesNo($id, $title, $allowClear = FALSE, $required = NULL, $attributes = array()) { $attributes += array('id_suffix' => $id); $choice = array(); @@ -846,6 +869,17 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } } + /** + * @param $id + * @param $title + * @param $values + * @param null $other + * @param null $attributes + * @param null $required + * @param null $javascriptMethod + * @param string $separator + * @param bool $flipValues + */ function addCheckBox($id, $title, $values, $other = NULL, $attributes = NULL, $required = NULL, $javascriptMethod = NULL, @@ -928,6 +962,15 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->addButtons($buttons); } + /** + * @param $name + * @param string $from + * @param string $to + * @param string $label + * @param string $dateFormat + * @param bool $required + * @param bool $displayTime + */ function addDateRange($name, $from = '_from', $to = '_to', $label = 'From:', $dateFormat = 'searchDate', $required = FALSE, $displayTime = FALSE) { if ($displayTime) { $this->addDateTime($name . $from, $label, $required, array('formatType' => $dateFormat)); @@ -1022,6 +1065,12 @@ class CRM_Core_Form extends HTML_QuickForm_Page { )); } + /** + * @param $name + * @param $label + * @param $attributes + * @param bool $forceTextarea + */ function addWysiwyg($name, $label, $attributes, $forceTextarea = FALSE) { // 1. Get configuration option for editor (tinymce, ckeditor, pure textarea) // 2. Based on the option, initialise proper editor @@ -1060,6 +1109,12 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->assign('includeWysiwygEditor', $includeWysiwygEditor); } + /** + * @param $id + * @param $title + * @param null $required + * @param null $extra + */ function addCountry($id, $title, $required = NULL, $extra = NULL) { $this->addElement('select', $id, $title, array( @@ -1070,6 +1125,14 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } } + /** + * @param $name + * @param $label + * @param $options + * @param $attributes + * @param null $required + * @param null $javascriptMethod + */ function addSelectOther($name, $label, $options, $attributes, $required = NULL, $javascriptMethod = NULL) { $this->addElement('select', $name . '_id', $label, $options, $javascriptMethod); @@ -1079,18 +1142,30 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } } + /** + * @return null + */ public function getRootTitle() { return NULL; } + /** + * @return string + */ public function getCompleteTitle() { return $this->getRootTitle() . $this->getTitle(); } + /** + * @return CRM_Core_Smarty + */ static function &getTemplate() { return self::$_template; } + /** + * @param $elementName + */ function addUploadElement($elementName) { $uploadNames = $this->get('uploadNames'); if (!$uploadNames) { @@ -1116,6 +1191,9 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } } + /** + * @return string + */ function buttonType() { $uploadNames = $this->get('uploadNames'); $buttonType = (is_array($uploadNames) && !empty($uploadNames)) ? 'upload' : 'next'; @@ -1123,10 +1201,19 @@ class CRM_Core_Form extends HTML_QuickForm_Page { return $buttonType; } + /** + * @param $name + * + * @return null + */ function getVar($name) { return isset($this->$name) ? $this->$name : NULL; } + /** + * @param $name + * @param $value + */ function setVar($name, $value) { $this->$name = $value; } @@ -1371,6 +1458,9 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } } + /** + * @param $elementName + */ function removeFileRequiredRules($elementName) { $this->_required = array_diff($this->_required, array($elementName)); if (isset($this->_rules[$elementName])) {