Skip to content
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

Merged
merged 4 commits into from
Mar 27, 2017
Merged

Conversation

gluneau
Copy link
Contributor

@gluneau gluneau commented Mar 22, 2017

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:

  • When file is required
    • Will fail when file not provided.
    • Will pass when file is provided.
  • When file is not required
    • Will pass when file not provided.
    • Will pass when file is provided.

@gluneau gluneau added the Bug PR or issue introducing/requiring bug fixes (not mutually exclusive with the Feature label) label Mar 22, 2017
@gluneau gluneau added this to the 17.0 milestone Mar 22, 2017
$value = $el['name'];
if (isset($el['required'])
&& $el['required'] === true
&& empty($value)
Copy link
Contributor

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.

@jstirling91 jstirling91 added the Needs Work PR awaiting additional changes by the author or contains issues that the author needs to fix label Mar 23, 2017
@gluneau gluneau removed the Needs Work PR awaiting additional changes by the author or contains issues that the author needs to fix label Mar 23, 2017
} 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"
Copy link
Contributor

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

@gluneau
Copy link
Contributor Author

gluneau commented Mar 24, 2017

@jstirling91 Please re-review.

@driusan driusan merged commit ce9f386 into aces:17.0-dev Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug PR or issue introducing/requiring bug fixes (not mutually exclusive with the Feature label)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants