[Django] #25078: Support disabled fields

11 views
Skip to first unread message

Django

unread,
Jul 7, 2015, 3:08:41 PM7/7/15
to django-...@googlegroups.com
#25078: Support disabled fields
---------------------------------------+------------------------
Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+------------------------
I'd like to propose adding support for disabled form fields in Django.
If it were only a matter of adding widget attributes, like it's feasible
with the `readonly` attribute, it wouldn't need special treatment.
However, the `disabled` attribute is particular in that user agents are
not transmitting their values when POSTing form data.

A typical use case is a ModelForm where you'd like to disable some fields
while still displaying all values. So currently, if you simply add
`disabled` to the widget attributes, you'll have a problem: the form will
clear the field as the value is not present in the data (and the field is
not in excluded fields).

--
Ticket URL: <https://code.djangoproject.com/ticket/25078>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 7, 2015, 3:11:53 PM7/7/15
to django-...@googlegroups.com
#25078: Support disabled fields
-----------------------------+--------------------------------------

Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by claudep):

* needs_docs: 0 => 1
* has_patch: 0 => 1


Comment:

POC pull request: https://github.com/django/django/pull/4958

--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:1>

Django

unread,
Jul 8, 2015, 2:15:19 PM7/8/15
to django-...@googlegroups.com
#25078: Support disabled form fields
-----------------------------+------------------------------------

Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


Comment:

I'd suggest to write to the mailing list to get some ideas for this. An
implementation that reduces the amount of admin-specific code needed for
`ModelAdmin.readonly_fields` might be interesting (#342 / [bcd9482a20]).

--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:2>

Django

unread,
Jul 9, 2015, 5:32:22 AM7/9/15
to django-...@googlegroups.com
#25078: Support disabled form fields
-----------------------------+------------------------------------
Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by claudep):

`ModelAdmin.readonly_fields` has chosen another route, that is displaying
the value of the field instead of displaying a disabled form widget
containing the value. I can write to the mailing list, but I'm not sure
about what sort of ideas I would ask for.

--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:3>

Django

unread,
Jul 9, 2015, 6:41:35 AM7/9/15
to django-...@googlegroups.com
#25078: Support disabled form fields
-----------------------------+------------------------------------
Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by timgraham):

Do you prefer or require disabled form widgets as opposed to displaying
the values? Just curious.

--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:4>

Django

unread,
Jul 9, 2015, 12:24:30 PM7/9/15
to django-...@googlegroups.com
#25078: Support disabled form fields
-----------------------------+------------------------------------
Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by claudep):

Displaying a value is triggering a whole different machinery, as the
`readonly_fields` admin patch shows. I think what we address in this issue
is a lot simpler as we simply rely on a HTML attribute. I think that
displaying the disabled form widget makes sense as we are still in the
context of displaying a form, but for whatever reason, some field is not
editable by the current user.

--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:5>

Django

unread,
Jul 11, 2015, 4:27:48 AM7/11/15
to django-...@googlegroups.com
#25078: Support disabled form fields
-----------------------------+------------------------------------
Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by claudep):

* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:6>

Django

unread,
Jul 15, 2015, 9:27:34 AM7/15/15
to django-...@googlegroups.com
#25078: Support disabled form fields
-----------------------------+---------------------------------------------

Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:7>

Django

unread,
Jul 16, 2015, 1:37:41 PM7/16/15
to django-...@googlegroups.com
#25078: Support disabled form fields
-----------------------------+---------------------------------------------
Reporter: claudep | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: 1.8
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------------
Changes (by Claude Paroz <claude@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"1ef4aeab403f7fb74c0b9b11fde854fd03afc40c" 1ef4aeab]:
{{{
#!CommitTicketReference repository=""
revision="1ef4aeab403f7fb74c0b9b11fde854fd03afc40c"
Fixed #25078 -- Added support for disabled form fields

Thanks Keryn Knight and Tim Graham for the reviews.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25078#comment:8>

Reply all
Reply to author
Forward
0 new messages