Changes between Version 2 and Version 3 of CookBookNewFormsDynamicFields


Ignore:
Timestamp:
Jan 1, 2008, 10:39:24 AM (17 years ago)
Author:
Todd O'Bryan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBookNewFormsDynamicFields

    v2 v3  
    2828}}}
    2929
    30 When you display this form, you'll get separate spot to answer each of the questions you passed in, each with its own index so that you can match it to the question. One complication--if you choose to use this method, you have to pass the same `questions` list each time you create the form, both on the GET when it's empty and on the POST when it has your answers. It is possible to avoid this, but it takes a little more thought when you set up your views and the workflow. (Saving stuff in the session can make things much easier.)
     30When you display this form, you'll get a separate spot to answer each of the questions you passed in, each with its own index so that you can match it to the question. One complication--if you choose to use this method, you have to pass the same `questions` list each time you create the form, both on the GET when it's empty and on the POST when it has your answers. It is possible to avoid this, but it takes a little more thought when you set up your views and the workflow. (Saving stuff in the session can make things much easier.)
    3131
    3232This technique isn't limited to defining new fields. You can also set a field's `initial` value in the `__init__` method, which is really helpful when your forms depend on your models, but don't match up exactly so you can't use the `ModelForm` framework.
Back to Top