Description
The description added by @Sgoettschkes in symfony/symfony-docs#2114 states:
If you don't want a user to modify the value of a field, you can set the disabled option to true. Any submitted value will be ignored.
I only found this short discussion about readonly
and disabled
:
symfony/symfony-docs#2096
Personally I always regarded readonly
as being what is now described in the docs as disabled
.
The disabled
option in HTML was designed to be enabled
again.
In my simple use case I have a radio button addFoo
that was checked with the value 1
resp. true
.
The Client then enables a dependent choice via JS.
The form now expects the user to select a value from a choice widget selectFoo
that was disabled
by default.
After submitting the form should be invalid because a constraint is used to check if a selection has been made since addFoo
was checked. Of course now selectFoo
should no longer be disabled.
This can be handled by the SUBMIT
event where I re-add the element being enabled.
So far so good!
But if I check addFoo
and DO select a choice in selectFoo
and submitting the form then fails because of a different error the selectFoo
is not being populated because the original choice field type - before enabling it in the SUBMIT
event - had the disabled
option.
The code:
https://gist.github.com/webdevilopers/5306ee3417791227abf3
Should we re-consider the functionality of the disabled
option when setting data on the form?
Or how should this use case (Disabled field gets enabled on client side and needs to be populated afterwards) be handled?
Will dependent form fields
solve this "issue"?
#5807
Possibly related issues: