[support] Multipart Form in 6.x

Metzler, David metzlerd at evergreen.edu
Fri Jan 15 16:07:43 UTC 2010


#type=> value should show up in your validate functions as submitted
data in $form_state['values']. 

>From the #type=>value forms reference: 

Note that as of Drupal 6, you can also simply store arbitrary variables
in $form['#foo'] instead, as long as '#foo' does not conflict with any
other internal property of the Form API.

You really should be able to do this, just make sure its not objects,
but structured data should work. 

Dave

-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of David Spindler
Sent: Thursday, January 14, 2010 10:17 PM
To: support at drupal.org
Subject: [support] Multipart Form in 6.x

I'm trying to figure out the magic of a multipart form.

I'm trying to have a user register his family. So he goes to a form
which has a blank for one person and he keeps clicking "Add another
person" until he has enough blanks for all his family members at which
point he can hit "Save" and it's processed.

Currently I'm doing this in form_validate. If they clicked the Add
Another Person button I called form_set_error('',''). Which returns them
to the form w/o giving them an error. All the form data is still filled
in. If the click the Save button I validate and return and
form_submit() is called which saved the data.

I'm trying to figure out how to pass hidden data so that it can't be
tampered with (For example a family id). Initially I was using a hidden
field with a #value (as opposed to #default_value) under the assumption
that Drupal would validate the field for me and ensure it was not
changed. This doesn't seem to be the case and I'm trying to figure out
another way to keep data with my form w/o having it tampered with. I
tried using a field of #type 'value', but that didn't seem to get passed
back into with the $form_state for the next iteration. A couple of
thoughts I had.

1. Validate the hidden data myself in the validate function comparing
$form_state and $form.
2. Change the way I'm doing this to a more drupal approved way so that
it will validate my hidden data for me? (Is there a flag I can set) 3.
Figure out how to get value fields passed  between form submissions.


Thanks, David
--
[ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list