Code

Opened 7 years ago

Closed 7 years ago

#3122 closed defect (invalid)

newforms: {{ form.field.label }} should output <label> when auto_id present

Reported by: Eric <cephelo@…> Owned by: adrian
Component: Forms Version: master
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

class MyForm(Form):
    field = CharField(label="Test")

def myview(request):
    form = MyForm(auto_id="id_%s")
    return render_to_response("test.html", {"form": form})

# test.html
{{ form.field.label }}

yields "Test". As auto_id is set, I would expect this to output <label for="id_field">Test:</label>, as form.as_table and other functions already do. If you don't want the <label>, you won't be using auto_id anyway.

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by Eric <cephelo@…>

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

Nevermind, marking invalid. This can already be done, just not as the default behavior as I expected. In case anyone ends up here from searching, you can already do this using

form.field.label_tag

Or in your template as {{ form.field.label_tag }}.

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.