X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FForm.php;h=1ecbbede88734d9c028a39123c08580e2f606b53;hb=2817d84b3736cb0c6051fd9fac875e85f8497caa;hp=9aee8a8933c2bca8a0eb97b1d05e75ea16ccdf90;hpb=2da40d216d22a8f768c53921644d040667a1713e;p=civicrm-core.git diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 9aee8a8933..1ecbbede88 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -152,7 +152,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { private $_chainSelectFields = array(); /** - * Constructor for the basic form page + * Constructor for the basic form page. * * We should not use QuickForm directly. This class provides a lot * of default convenient functions, rules and buttons @@ -361,7 +361,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } /** - * The postProcess hook is typically called by the framework + * The postProcess hook is typically called by the framework. * However in a few cases, the form exits or redirects early in which * case it needs to call this function so other modules can do the needful * Calling this function directly should be avoided if possible. In general a @@ -388,10 +388,11 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * access public * - * @return array + * @return array|NULL * reference to the array of default values */ public function setDefaultValues() { + return NULL; } /** @@ -408,7 +409,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Performs the server side validation * @since 1.0 - * @return boolean + * @return bool * true if no error found * @throws HTML_QuickForm_Error */ @@ -501,10 +502,11 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Add default Next / Back buttons * - * @param array array of associative arrays in the order in which the buttons should be - * displayed. The associate array has 3 fields: 'type', 'name' and 'isDefault' - * The base form class will define a bunch of static arrays for commonly used - * formats + * @param array $params + * Array of associative arrays in the order in which the buttons should be + * displayed. The associate array has 3 fields: 'type', 'name' and 'isDefault' + * The base form class will define a bunch of static arrays for commonly used + * formats. * * @return void */ @@ -513,6 +515,10 @@ class CRM_Core_Form extends HTML_QuickForm_Page { foreach ($params as $button) { $attrs = array('class' => 'crm-form-submit') + (array) CRM_Utils_Array::value('js', $button); + if (!empty($button['class'])) { + $attrs['class'] .= ' ' . $button['class']; + } + if (!empty($button['isDefault'])) { $attrs['class'] .= ' default'; } @@ -619,7 +625,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Setter function for options * - * @param mixed + * @param mixed $options * * @return void */ @@ -642,7 +648,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Boolean function to determine if this is a one form page * - * @return boolean + * @return bool */ public function isSimpleForm() { return $this->_state->getType() & (CRM_Core_State::START | CRM_Core_State::FINISH); @@ -660,7 +666,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Setter function for Form Action * - * @param string + * @param string $action * * @return void */ @@ -709,10 +715,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $tplname = $ext->getTemplatePath(CRM_Utils_System::getClassName($this)) . DIRECTORY_SEPARATOR . $filename; } else { - $tplname = str_replace('_', - DIRECTORY_SEPARATOR, - CRM_Utils_System::getClassName($this) - ) . '.tpl'; + $tplname = strtr( + CRM_Utils_System::getClassName($this), + array( + '_' => DIRECTORY_SEPARATOR, + '\\' => DIRECTORY_SEPARATOR, + ) + ) . '.tpl'; } return $tplname; } @@ -762,9 +771,10 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Store the variable with the value in the form scope * - * @param string name : name of the variable - * @param mixed value : value of the variable - * + * @param string $name + * Name of the variable. + * @param mixed $value + * Value of the variable. * * @return void */ @@ -775,8 +785,8 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Get the variable from the form scope * - * @param string name : name of the variable - * + * @param string $name + * Name of the variable * * @return mixed */ @@ -1276,20 +1286,23 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Add date - * @param string $name - * Name of the element. - * @param string $label - * Label of the element. - * @param array $attributes - * Key / value pair. * + * @code * // if you need time * $attributes = array( * 'addTime' => true, * 'formatType' => 'relative' or 'birth' etc check advanced date settings * ); + * @endcode + * + * @param string $name + * Name of the element. + * @param string $label + * Label of the element. * @param bool $required * True if required. + * @param array $attributes + * Key / value pair. */ public function addDate($name, $label, $required = FALSE, $attributes = NULL) { if (!empty($attributes['formatType'])) { @@ -1566,7 +1579,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * - cid from the url if the caller has ACL permission to view * - fallback is logged in user (or ? NULL if no logged in user) (@todo wouldn't 0 be more intuitive?) * - * @return NULL|integer + * @return NULL|int */ public function getContactID() { $tempID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); @@ -1683,6 +1696,8 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * that small pieces of duplication are not being refactored into separate functions because their only shared parent * is this form. Inserting a class FrontEndForm.php between the contribution & event & this class would allow functions like this * and a dozen other small ones to be refactored into a shared parent with the reduction of much code duplication + * + * @param $onlinePaymentProcessorEnabled */ public function addCIDZeroOptions($onlinePaymentProcessorEnabled) { $this->assign('nocid', TRUE);