Skip to content
Snippets Groups Projects
Commit 2f8f4f9c authored by DaveD's avatar DaveD
Browse files

avoid E_WARNING and remove code

parent fe7338a3
Branches
Tags
No related merge requests found
......@@ -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])) {
......
......@@ -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;
},
],
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment