Home › Forums › Quform PHP › Process a multidimensional input array
- This topic has 1 reply, 1 voice, and was last updated 8 years, 9 months ago by estin92.
- AuthorPosts
- February 7, 2016 at 8:01 pm #18141estin92Participant
Hi,
I’m currently putting together an invitation website for my wedding which is processing multiple guests being booked by one person.
I’ve constructed a big of javascript to repeat a form section to capture each guests first name, last name, meal choices and diet requirements. This is captured using the following pattern on inputs/selects:
<input type="text" class="form_input required" name="guest[1][first_name]" />
<input type="text" class="form_input required" name="guest[1][last_name]" />
I can see that this is being captured by dumping the contents of $_POST[‘guest’] and $_POST[‘guest’][1], but I can’t seem to get it to be processed via Quform. It instead keeps telling me that these fields are required, breaks to show the error and therefore won’t process the form
At the moment, I’ve got a while loop running and I’m using the index of that loop to keep progress and tap into each guest.. For some reason I feel I’ve missed something stupid but I’m drawing a blank at the moment. This is how it’s currently being captured:
$first_name = new Quform_Element('guest['.$loop_count.'][first_name]', 'Guest first name');
$first_name->addFilter('trim');
$first_name->addValidator('required');
$form->addElement($first_name);
Any help is massively appreciated!
February 8, 2016 at 8:04 am #18142estin92ParticipantIt was indeed something stupid.. I was missing the ‘setIsArray’ on my processing.
$element->setIsArray(true);
- AuthorPosts
- You must be logged in to reply to this topic.