Hi,
I wish a form with several fields and several checkboxes habing the
same name to collect a list of persons. In HTML I would write (summary
without html details, and there are 12 other fields):
<pre>
Project <input type="text" name="project" id="id_project" />
Bob <input type="checkbox" name="persons" value="1"
id="id_persons_0" />
Alice <input type="checkbox" name="persons" value="2"
id="id_persons_1" />
John <input type="checkbox" name="persons" value="3"
id="id_persons_3" />
</pre>
The user can then select from 0 to all persons that work on a
project.
The list of persons is fetched from the database, so I do not know at
first how many persons nor their names.
Then on processing the form, I wish I could retrieve the persons such
as a list of values in order to store it in my data backend.
<pre>
>>> dict(form.d)
{'persons': [u'2', u'3'], 'project': 'Clean code'}
</pre>
The only information I have found is the following message:
http://groups.google.com/group/webpy/browse_thread/thread/ae7c8b6317b89e3a/bd13ae763686d284?lnk=gst&q=multiple+checkbox#bd13ae763686d284
But this solution would create one named checkbox per person, which I
cannot easily process afterward.
Currently I am using two forms, one for all the fields except the
checkboxes, and one dedicated to the fields.
But I am not satisfied with this solution.
Is this currently feasible in web.py using its form module?
If not, would implementing a new MultipleCheckbox input be a clean way
to achieve my need with regard to web.py "philosophy"?
Thanks,
r.
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.