diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index a3ef1cc1a20552ea52511bb9392dc7a64feb4980..7d48b6569e0a1620a650ca1427ed551688dbcfa2 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -439,7 +439,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page { unset($extra['option_context']); } - $this->addRequiredAttribute($required, $extra); $element = $this->addElement($type, $name, CRM_Utils_String::purifyHTML($label), $attributes, $extra); if (HTML_QuickForm::isError($element)) { CRM_Core_Error::statusBounce(HTML_QuickForm::errorMessage($element)); @@ -1174,20 +1173,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page { return self::$_template->get_template_vars($name); } - /** - * jQuery validate prefers to see a validation rule as a class (eg. "required"). - * We can't add a class at the quickform level but jQuery validate also works with HTML5: - * HTML5 validation requires a separate attribute "required". - * - * @param $required - * @param $attributes - */ - private function addRequiredAttribute($required, $attributes) { - // Ideally we do this by adding "required" as a class on the radio but we can't - // But adding the attribute "required" directly to the element also works. - $required ? $attributes['required'] = 1 : NULL; - } - /** * @param string $name * @param $title @@ -1205,8 +1190,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $allowClear = !empty($attributes['allowClear']); unset($attributes['allowClear']); $attributes['id_suffix'] = $name; - // For jquery validate we need to flag the actual radio as required. - $this->addRequiredAttribute($required, $attributes); foreach ($values as $key => $var) { $optAttributes = $attributes; if (!empty($optionAttributes[$key])) { diff --git a/tests/phpunit/CRM/Core/FormTest.php b/tests/phpunit/CRM/Core/FormTest.php index c55826cee59865938f23b93517bee87bd6cfbab1..57bca3e47b272206c08aadaddabef5cc2f4a0e6d 100644 --- a/tests/phpunit/CRM/Core/FormTest.php +++ b/tests/phpunit/CRM/Core/FormTest.php @@ -65,6 +65,13 @@ class CRM_Core_FormTest extends CiviUnitTestCase { $form->_action = CRM_Core_Action::BASIC; }, ], + 'New Price Field' => [ + 'CRM_Price_Form_Field', + function(CRM_Core_Form $form) { + $form->set('sid', 1); + $form->_action = CRM_Core_Action::ADD; + }, + ], ]; }