On Apr 30, 4:00 pm, gsnyder2007 <gsnyder2...@gmail.com> wrote:
> I'm looking for a pointer to sample code or advice regarding what is
> the best way to build a form that allows the user to select from
> several options and supply additional textual input that is associated
> with the option they chose, e.g.
>
> choices = [
>     ('option1', 'value1'), # additional text input that is tied to
> this option
>     ('option2', 'value2'), # additional text input that is tied to
> this option
>     ('option3', 'value3'), # additional text input that is tied to
> this option
> ]
>
> The options (choices) are fixed (i.e not dynamic) but the input
> obviously is. I know how I could do this using a Model-based approach
> (the options become ForeignKey's to the Model class that collects the
> input), but is there an easy way to do this with forms, fields, and
> widgets? I tried playing around with MultiWidget and MultiField but
> couldn't put it together the way I wanted. Something tells me the
> obvious eludes me this morning. :-)

I am not sure of the specifics of the problem you are trying to solve,
but another way could be simply to make the "fixed choices" be "fixed
fields".  Then the " additional text input" becomes the value of the
field.  For example, if choices are:
MasterCard, VisaCard and/or Cheque Account.
These become fields and the user fills the name/number of the card or
account as the " additional text input".

Derek

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to