This is obviously borrowed from PHP but I think there are useful
reasons to copy this behavior.
The idea...
If one constructs their HTML forms, naming their form elements as
"name[key]" like so:
<input type="text" name="f[name]">
<input type="text" name="f[address]">
<input type="text" name="f[city]">
etc.
Django would then convert this to a dictionary of form:
f = {
'name': 'value of f[name]',
'address': 'value of f[address]',
'city': 'value of f[city]'
}
This is also useful for grouping multiple select boxes:
<select multiple name="selects[]">
<option value="1">One</option>
<option value="2">Two</option>
<option value="2">Three</option>
</select>
(I'm not sure how Django handles multiple selects currently.)
Processing within Django, to me, becomes simpler, and one can do
things like the following rather than iterating over all items in
request.POST:
if request.POST.has_key('f'):
for k,v in request.POST['f'].iteritems():
# process key/value pairs in some way
Grouping your forms into dicts like this also lets you do iterative
logic while avoiding other POST items (eg: input type=submit values or
X,Y coordinates).
I'm not sure how this would tie in with newforms since we're not using
Django's forms and validation (at least for now).
Cheers!
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---