Code

Opened 14 months ago

Closed 14 months ago

Last modified 14 months ago

#19880 closed Bug (fixed)

form-wizard initial data example is wrong

Reported by: almalki Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords: form-wizard formwizard wizard
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In this example there is a small error, basically it is calling as_view and then call methods on the returned function.

>>> wiz = ContactWizard.as_view([ContactForm1, ContactForm2], initial_dict=initial)
>>> form1 = wiz.get_form('0')

should be:

>>> wiz = ContactWizard([ContactForm1, ContactForm2], initial_dict=initial)
>>> form1 = wiz.get_form('0')

(assuming __init__ takes same arguments as as_view)

Attachments (1)

19880.diff (879 bytes) - added by timo 14 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 14 months ago by carljm

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

comment:2 Changed 14 months ago by carljm

#19886 was a duplicate.

comment:3 Changed 14 months ago by expleo

comment:4 Changed 14 months ago by expleo

  • Has patch set

comment:5 follow-up: Changed 14 months ago by timo

  • Has patch unset

Whoops, I had meant to comment on this but I left the comment on the duplicate ticket instead.

You can't initialize ContactWizard directly with a list of forms and the initial dict. The as_view call is correct, but then you need to pass request to the function that's returned. Maybe RequestFactory could be used for the example, but a session is also needed on the request so it seems a bit complicated to have this example use the shell.

comment:6 in reply to: ↑ 5 Changed 14 months ago by expleo

Replying to timo:

Whoops, I had meant to comment on this but I left the comment on the duplicate ticket instead.

You can't initialize ContactWizard directly with a list of forms and the initial dict. The as_view call is correct, but then you need to pass request to the function that's returned. Maybe RequestFactory could be used for the example, but a session is also needed on the request so it seems a bit complicated to have this example use the shell.

I agree, not changing the docs seems the best option in this case.

Changed 14 months ago by timo

comment:7 Changed 14 months ago by timo

  • Has patch set

I think we should make some sort of fix since it's misleading as is. How about the attached?

comment:8 Changed 14 months ago by Tim Graham <timograham@…>

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

In a97c441e18684570fbecd47b19bd47b4c06cc565:

[1.5.X] Fixed #19880 - Fixed an error in the form wizard initial_dict example.

Thanks almalki for the report.

Backport of 9b97f01dea from master

comment:9 Changed 14 months ago by Tim Graham <timograham@…>

In 9b97f01dea093de484366924842c89550472d0b6:

Fixed #19880 - Fixed an error in the form wizard initial_dict example.

Thanks almalki for the report.

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.