-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LorisForm] allow files to validate #2675
Conversation
php/libraries/LorisForm.class.inc
Outdated
$value = $el['name']; | ||
if (isset($el['required']) | ||
&& $el['required'] === true | ||
&& empty($value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always be false, even if the file isn't submitted with the form.
…custom fail" section of validate
php/libraries/LorisForm.class.inc
Outdated
} else if ($el['type'] === 'file') { | ||
$value = $_FILES[$el['name']]['name']; | ||
// $el['required'] not present in the file $el array | ||
// the file required will get cought by "custom fail" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gluneau
copy 1180 to 1186 to your code changes for additional logic
@jstirling91 Please re-review. |
Fixes the problem where in the else section of validate the
$value = $this->getValue($el['name']);
would use the LorisForm::getValue rather than LorisFormFileElement::getValue
When using XINRules, file are always required by default, add this rule if your file element is not required:
$this->XINRegisterRule("vineland_file", array("vineland_file{@}==={@}NEVER_REQUIRED"));
NOTE: the triple equal in the rule!!
I tested this with: