Process a multidimensional input array

Home Forums Quform PHP Process a multidimensional input array

This topic is: resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #18141
    estin92
    Participant

    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!

    #18142
    estin92
    Participant

    It was indeed something stupid.. I was missing the ‘setIsArray’ on my processing.

    $element->setIsArray(true);

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy