-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
ValidationScope: User unfriendly implementation #111
Comments
What about condition? $form->addSelect('country', 'Country:', $countries);
$form->addSubmit('submit', 'Send');
$form['country']
->addConditionOn($form['submit'], $form::SUBMITTED)
->setRequired('Choose country'); |
How does this help me when I have those countries loaded using AJAX and have Sorry if I haven't made myself clear about that. |
Why you need to disable scope validation for select? |
Because I am stupid, |
@dg I am closing this as it is probably unnecessary to have it here. |
@dg I have to disable validation scope when I use The problem is when I submit form with AJAX data, the value of select is outside I am back to my initial issue, disabling validation scope in this way is not friendly. |
Can you try to implement any solution? |
@dg Well I have a few ideas First idea
Second idea
Third idea
What do you think? Does any of those sound good? |
Why not just set EDIT: Seems like we would need to modify EDIT: No we can't do it, it would be a BC break. |
@JanTvrdik Yeah, it is particularly troubling issue this one. I don't mind working with validation scope, it's just not very intuitive to work with. |
I don't think that validation scopes should be used for this kind of issue at all. Another random idea $form->addSelect('country', 'Country', [$form->getHttpData('country') => '...'])
->setRequired(); |
Really? Why? With your another random idea, I see potential problem with setting default value for editing. |
@juniwalk Because if you don't want the value to be validated, you should not make the select box required. What's the point of setting validation rules if they should be ignored? |
@JanTvrdik I do want the value validated, and I need it to be required, but that does not play well with AJAX values feeded in to the select box ... |
Could you elaborate on what exactly and where do you validate? |
@JanTvrdik In this context I ment the requirement validation as i use this to suggest user names and I get back just int (user Id) which I then in the onSuccess (probably not properly done but that is how I use it). |
I'm sorry, I still don't understand it. How could you use the server-side validation when the select box is not validated at all because it is not included in the validation scope? What did I miss? |
@JanTvrdik Ignore it, we diverged from the problem here, validation is not the issue, getting the value is. |
@JanTvrdik Yes, and to disable the scope is absolute horrendous work to do (especially for large forms). |
edit: |
@dg Hey, now that looks much better, would you mind if I send PR to docs with this example to help others like me? |
Of course I'll be happy. But try it please, I wrote from my head. |
@dg So I tried that array_diff_key and it throws an error EDIT: I'd have to combine it with |
Hi, I was modifying it before to keep the clientSide validation so user gets alerted before submitting that he did not select something required, however I can live without it. I think we can close this issue. |
Hello,
I'd like to ask, could we come up with some way to rework disabling validation scope for selected fields?
Currently if you have 17 fields and one of them is AJAXified
<select>
, you have to do this:Best way would be to disable this per-field.
The text was updated successfully, but these errors were encountered: