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