#3427 closed (wontfix)
newforms: add readonly support to widgets
Reported by: | anonymous | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
readonly= is an integral part of some Intranet applications and is currently lacking from newforms. The documentation should probably state that, of course, if you really want something to be readonly, you cannot put it in a form at all, but for the rest of us, readonly is an easy solution.
The only problems are that select fields don't have a readonly= property. I've seen them rendered as <input type="text" /> instead, or you can use <select disabled=disabled" /> and automatically append an <input type="hidden" /> with the real readonly value (<select /> fields cannot have readonly as a UI restriction, e.g., UAs don't allow it).
disabled= may also be useful.
Change History (6)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:3 by , 18 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
Is it really so hairy?
Why not just use the disabled and NOT do the hidden input thing. Disabled in IMHO is a better way to specify read-only stuff on a form, since it means that the input won't be submitted as part of the form. People who expect it to always be submitted as part of the form need the hidden input because of this, but its better to write server-side code such that it knows NOT to expect a value for such a disabled field.
Because... of the following scenario:
- user GETs your page with a form in it, containing inputs marked readonly
- user saves the html locally
- user edits the form, removing the readonly attributes
- user submits the edited form, and since your server-side code does not check that the values should not change, the user bypasses the fact that you made them read-only
-i
comment:4 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
Hi iwan,
Please don't reopen tickets that have been marked as "wontfix."
comment:5 by , 18 years ago
(and in reply to the comment...)
It is indeed better to do this server-side; if you have a field which should not be submitted back, the form should not include that field at all. Instead, as Adrian suggested, the value should just be displayed normally and not as a form field of any sort.
I'm marking this as wontfix because the issue with
<select>
fields is too hairy to be worth it, and you can achieve the same thing by simply displaying the current value of a form's field in your template.