Opened 7 years ago

Closed 7 years ago

#28733 closed New feature (wontfix)

Formsets are missing classes to be easily styleable

Reported by: Claude Paroz Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

With normal forms, it's easy to style widgets with CSS thanks to unique input ids (input#id_field_name selector).

With formsets, as ids contain an index number, you cannot use the same strategy. To add some class to some field widget, you have to customize the formset form to add a custom widget to be able to specify an attrs={'class': 'special'}) parameter, which is much boilerplate code for a very common and simple addition.

I would suggest to automatically add class="fieldname" on each formset widget.

Change History (2)

comment:1 by Tim Graham, 7 years ago

I think a fairly strong justification is needed given the possibility that some unwanted CSS rules in a developer's stylesheet might start appearing on form fields. Did you consider using a CSS rule like input[id$="-field_name"]?

comment:2 by Claude Paroz, 7 years ago

Resolution: wontfix
Status: newclosed

Ah thanks, awesome CSS3 selectors! Sorry for the noise.

Note: See TracTickets for help on using tickets.
Back to Top