-
Notifications
You must be signed in to change notification settings - Fork 19
Fix uncheck checkbox and submit input type hidden value #36
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
Fix uncheck checkbox and submit input type hidden value #36
Conversation
|
Wouldn't it be better to check if Checkbox field is unchecked and then skip it. Browsers process form fields in a linear fashion (that's the point of putting hidden field before checkbox). Could you check if skipping unchecked fields work? Before: foreach ($fields as $field) {
if ($field instanceof FileFormField || $field->isDisabled() || !$field->hasValue()) {
continue;
}
// ...
}After: foreach ($fields as $field) {
if ($field instanceof FileFormField || $field->isDisabled() || !$field->hasValue()) {
continue;
}
if ($field instanceof CheckboxField && $field->isChecked() === false) {
continue;
}
// ...
} |
|
The issue is that the symfony component does not add all fields to the form... It essentially deduplicates based on name too early |
|
Ah, it is a WONTFIX issue: symfony/symfony#11689 |
|
Yeah, so the question is do we want to work around it via the solution proposed by @SOHELAHMED7 ? |
|
It seems that a better solution would be to stop using Symfony\Component\DomCrawler\Form, extract all fields using Crawler and do all processing in InnerBrowser code, but it is a lot of work. So a simple fix like this will have to do for now. |
|
Do you mean to say like this 0d03718 ? |
Current status
When a form have following inputs:
and when checkbox is unchecked and then if the form is submitted, value
'0'ofcoffeeis not sent.Ideally it should.
This PR fix that issue.
Failing test: d56484c
@SamMousa
Have any questions, feel free to ask