Commit 0f176f2e authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Make the 'required' rule listen to 'required' => false

parent cd8f92b9
......@@ -27,22 +27,25 @@
/**
* Checks whether the field has been specified.
*
* @param Pieform $form The form the rule is being applied to
* @param string $field The field to check
* @param array $element The element to check
* @param Pieform $form The form the rule is being applied to
* @param string $field The field to check
* @param array $element The element to check
* @param string $check Whether to check the element
* @return string The error message, if the value is invalid.
*/
function pieform_rule_required(Pieform $form, $value, $element) {
$function = 'form_is_empty_' . $element['type'];
if (function_exists($function)) {
if ($function($value, $element)) {
return $form->i18n('required');
function pieform_rule_required(Pieform $form, $value, $element, $check) {
if ($check) {
$function = 'form_is_empty_' . $element['type'];
if (function_exists($function)) {
if ($function($value, $element)) {
return $form->i18n('required');
}
return;
}
return;
}
if ($value == '') {
return $form->i18n('required');
if ($value == '') {
return $form->i18n('required');
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment