-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Skip required validation when field is hidden by 'hide if exist' and has existing value. #2622
Skip required validation when field is hidden by 'hide if exist' and has existing value. #2622
Conversation
Fixes form submit when required field gets hidden because of the ‘hide if value exist’ behaviour. Else form will halt and returns that x field is required, but this field is not shown on the frontend.
?? |
@@ -214,6 +214,12 @@ public function saveSubmission($post, $server, Form $form, Request $request = nu | |||
} | |||
|
|||
if ($f->isRequired() && empty($value)) { | |||
|
|||
//field is required, but hidden from form because of 'ShowWhenValueExists' | |||
if( null !== $f->getShowWhenValueExists() && $f->getShowWhenValueExists() === false ){ |
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.
Shouldn't this line be just:
if ($f->getShowWhenValueExists() === false ) {
because if something === false
, the !== null
part must be true as well, mustn't it?
Won't this skip validation for all fields set to show when value exists? Shouldn't we do a check on |
…ow a field if the lead data is an empty string and not just null
I updated to only bypass validation if the field is not part of $post |
It seems to be working well 👍 |
Description:
Fixes form submit when previously a required field with the behaviour "Hide if value exist" was filled in. Now the form submits without return an error for the required field.
Steps to test this PR:
Steps to reproduce the bug: