Code

Opened 7 years ago

Closed 7 years ago

#4511 closed (wontfix)

Missing useful ID attribute in <p>, <li> and <tr> of auto generated form from as_p, as_ul and as_table.

Reported by: gustavo@… Owned by: adrian
Component: Forms Version: master
Severity: Keywords: as_p,as_ul,as_table,id
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Design a form built with Form.as_p(), Form.as_ul() or Form.as_table() is dificult becouse there is no ID in <li>,<p> or <tr> tags.

For example: The <input> field "name" need to be larger than the others. I can do that with <input> tag becouse it have an id="id_name", but if I need to do some changes on the entire block containing the "name" field, it´s impossible.

Current form generation:
<li><label for="id_name">Name:</label><input id="id_name"/></li>

Proposed way:
<li id="name"><label for="id_name">Name:</label><input id="id_name"/></li>

This ID attribute is very useful when doing form design, please considere it.

I change the forms.py file from newforms package to act as proposed, and it´s included in this ticket as a patch.

Attachments (2)

forms.py (13.1 KB) - added by gustavo@… 7 years ago.
newforms/forms.py changed to have ID attribute in <p>, <ul> and <tr>
forms-patch.py (2.0 KB) - added by gustavo@… 7 years ago.
The patch

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by gustavo@…

newforms/forms.py changed to have ID attribute in <p>, <ul> and <tr>

comment:1 Changed 7 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

The as_* methods aren't intended to cover every conceivable need of form layout -- they're provided as useful conveniences when you just need a simple/default form layout and don't feel like writing the HTML for it. If you need more customized presentation of the form, don't use the as_* methods, and instead build the HTML yourself, dropping in fields from the form as needed.

comment:2 Changed 7 years ago by SmileyChris

  • Resolution set to wontfix
  • Status changed from new to closed

I concur with ubernostrum, this is probably outside of what is needed for most people.

Gustavo: in the future, if you could provide a diff rather than just a copy of the whole file, it would be appreciated!

Changed 7 years ago by gustavo@…

The patch

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.