#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 Changed 17 years ago by
Changed 17 years ago by
Attachment: | readonly_fields_v2.patch added |
---|
Newer patch, building on mir@noris' patch
Changed 17 years ago by
Attachment: | readonly_fields_v2.2.patch added |
---|
spell check, small bug fix, and models integration
comment:4 Changed 17 years ago by
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 Changed 16 years ago by
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 Changed 16 years ago by
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 Changed 16 years ago by
- I need a test ticket to see if the reporter is notified about responses -
comment:8 Changed 13 years ago by
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. :-)