-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] read_only field option should create a readonly input attribute #1974
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
Comments
+1 to changing this (in 2.1? it's likely a BC breaker) Imho, |
@fabpot, @stof, @bschussek: I was thinking about this. We should decided which way we choose... Do we go way to be compilant with W3C specs ? If so we will need to change behavior. Current If not we should note in docs that we are not compilant with W3C, and lists diffs in behavior. ps. I listed html4 spec, but AFAIK in html5 is almost identical, maybe just with more details. |
I am +1 for changing this, i stumbled accross this problem several times already. |
@stloyd could you be a little more verbose about "that field with this attr will be not send through form". if i get your point you don't want readonly fields to be processed by the form. i dont think that this would be a good decision and my usecase pretty much sums up for what kind of interaction input elements with readonly attribute are handy for. the w3c spec actually says that "Read-only elements may be successful.". grant them success :) |
@kmohrf My thought was that, there is no info that field with You simply got me wrong (or I was not precise), ps. I'm a bit confused now and I think I get myself into loop ^^ |
Is there any option to add readonly parameter to a collection field? Can't achieve that using "attr" in twig nor setAttribute in formbuilder. Disabled="disabled" isn't what i want, becouse it doesn't send post data. +1 for adding disabled and read_only to the formbuilder parameters array for text and email fields. |
not very original.... +1 for changing this ! |
+1 for changing this: I modified it #3037 |
@bschussek Can you give us your opinion here? Why it is as it is today? |
The implementation is as is because I wasn't fully aware of the W3C's details concerning "readonly" and "disabled", and because one option for making a field read-only seemed sufficient. Since this seems to cause confusion, we The documentation should clearly state that "read_only" fields are processed by the server, to prevent any potential security holes. This would be a BC break. @fabpot? |
@bschussek: Yes, that would break BC but I think this is needed. |
Maybe make read_only option configurable to clearly distinguish the cases: |
@Tobion Please, no. |
@stloyd, @bschussek: I could not quite grasp from the spec, how readonly fields should be treated on the server side, but .. it does not really make sense to me, that the posted values are processed normally. A readonly field makes sense only if it has a (default) value. You can of course make it dynamic (ie full name = first name + last name) with a bit of client side scripting, but this logic should imo be duplicated server side as well. Let's take a common user. He has no idea, how to edit the value of a readonly field and therefore binding the posted value server side equals to binding the default value. If we are dealing with a smart user though, she has control over the field, and can set it to whatever she prefers, perhaps even to something potentially risky. This might bring up wtf'y moments .. Based on that I propose readOnly fields to be bound based on default value, not the posted value. |
As |
sorry. damn keyboard shortcuts. what i wanted to say: |
It might be a little late the help, but I could solve this way: In TWIG template => {{ form_widget(form.field, { 'attr': { 'readonly': 'true' } }) }} Regards. |
hey,
i stumbled upon this field option and think it's not the right way to solve it
http://symfony.com/doc/current/reference/forms/types/text.html#read-only
the docs say, that the read_only parameter renders the field with a disabled attribute. even if disabled is the favored method of setting the field "not-editable" the parameter should be called disabled because there actually is a readonly attribute since html4 and it allows some kind of interaction that a disabled field does not.
in my case i have a text input that is filled with a value by a colorpicker. the color picker is triggered by the user clicking on that field. in contrast to a readonly input a disabled input is not clickable.
this is not a blocker as the readonly attribute can still be created by adding it to the attr parameter. i guess its still confusing though.
kind regards (and thanks for creating this)
konrad
The text was updated successfully, but these errors were encountered: