Opened 10 years ago

Closed 9 years ago

#23712 closed Bug (fixed)

BaseForm._html_output() uses inconsistent formatting for normal row

Reported by: A. Lloyd Flanagan Owned by: ppYang
Component: Forms Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by A. Lloyd Flanagan)

Steps to reproduce:

  1. Create a form with at least one HiddenInput form field.
  2. Override a method such as as_p() by calling _html_output() with:
    1. A normal_row parameter containing the string "%(field_name)s"
    2. A row_ender parameter which is *not* the last tag in normal_row
  3. Attempt to render the form. This will result in a builtins.KeyError: 'field_name' message.

Under these conditions, BaseForm._html_output() attempts to create a new row to hold the hidden input fields. When it does, it uses normal_row % {..}, but the dictionary does not have the field "field_name" in it. This causes a KeyError. On the other hand, if normal_row ends in a row_ender tag, it doesn't create a new row, and the method succeeds.

Change History (12)

comment:1 by A. Lloyd Flanagan, 10 years ago

Description: modified (diff)

comment:2 by Claude Paroz, 10 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug
Version: 1.7master

comment:3 by Joseph Gordon, 9 years ago

Owner: changed from nobody to Joseph Gordon
Status: newassigned

comment:4 by Wouter de Vries, 9 years ago

Has patch: set

comment:5 by Collin Anderson, 9 years ago

Needs documentation: set

comment:6 by Collin Anderson, 9 years ago

Needs documentation: unset
Patch needs improvement: set

comment:7 by Joseph Gordon, 9 years ago

Owner: Joseph Gordon removed
Status: assignednew

comment:8 by ppYang, 9 years ago

Owner: set to ppYang
Status: newassigned

I'll try to create a patch before this weekend.

comment:9 by Tim Graham, 9 years ago

Easy pickings: unset

Did you see the existing pull request and the questions on it?

in reply to:  9 comment:10 by ppYang, 9 years ago

Replying to timgraham:

Did you see the existing pull request and the questions on it?

Sorry, I thought it's unsigned and wasn't aware of wadevries' pull request.

And even worse, I just submitted another pull request...

Sorry for bother your guys, I should be more careful.

comment:11 by Tim Graham, 9 years ago

Patch needs improvement: unset

comment:12 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 3f9ec12d9c9eff9a3b1a205d87c7e66587cf9967:

Fixed #23712 -- Fixed KeyError with BaseForm._html_output()

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