Code

Opened 7 years ago

Closed 7 years ago

#3334 closed (fixed)

Dynamic Creation of newforms Persists field data

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

Description

Attached is a patch to the tests for newforms, showing that when passing in fields to dynamically created forms, the fields are persisting across multiple instances of the form.

The current test fails as attached, returning field1, field2, field3, and field4 on the second print statement, when it should just return field3 and field4.

Attachments (1)

form_tests.diff (1.8 KB) - added by Deryck Hodge <deryck@…> 7 years ago.
A patch to tests/regressiontests/forms/tests.py to test instances of dynamically created forms return the right fields.

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by Deryck Hodge <deryck@…>

A patch to tests/regressiontests/forms/tests.py to test instances of dynamically created forms return the right fields.

comment:1 Changed 7 years ago by adrian

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by adrian

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

(In [4437]) Fixed #3334 -- Changed newforms Form class construction so that appending to (or altering) self.fields affects only the instance, not the class. As a consequence, self.fields is created in Form.init(). The form metaclass now creates a variable self.base_fields instead of self.fields.

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.