#1714 closed enhancement (wontfix)
[patch] add "readonly" attribute to form fields
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Other) | Version: | magic-removal |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I often have forms with readonly fields. This patch adds an "readonly" attribute to all form fields, and an optional parameter to all init methods. For some elements (select and checkbox) it actually uses the "disabled" attribute, but it's much nicer to use "readonly" in init() consistently.
Attachments (3)
Change History (11)
comment:1 by , 19 years ago
by , 18 years ago
Attachment: | readonly_fields_v2.patch added |
---|
Newer patch, building on mir@noris' patch
by , 18 years ago
Attachment: | readonly_fields_v2.2.patch added |
---|
spell check, small bug fix, and models integration
comment:4 by , 18 years ago
Just a small note on the models patch, there is no purpose for it if you're just using contrib.admin, because that hides fields which aren't editable.
I still think it's useful to pass is_readonly
to a model's FormFields in case someone is doing something more low-level.
comment:5 by , 18 years ago
I still maintain this patch, but I'm tired of putting it here after each merge conflict. If you use this and want an up to date version, please contact me by email ;-)
comment:6 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I'm closing this since the old forms stuff is deprecated and new forms allow this in a more generic way.
comment:7 by , 18 years ago
- I need a test ticket to see if the reporter is notified about responses -
comment:8 by , 15 years ago
override admin.ModelAdmin like
def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == readOnlyField: kwargs["widget"] = AdminTextInputWidget(attrs={"readonly":"readonly"}) super(className, self).formfield_for_dbfield(db_field, **kwargs)
Um ... this will work better if you attach the patch. :-)