• Resolved gareth94

    (@atebol)


    Hello. Could anyone tell me how I can iterate through ‘Field Group’ values upon form submission please? I would like a PHP script to be ran where all of the form data will be inserted to various columns in an existing table of a MySQL database. Any support will be greatly appreciated ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @atebol

    I hope you are doing well.

    If we are on the same page you are looking for:

    /**
     * Action called before setting fields to database
     *
     * @since 1.0.2
     *
     * @param Forminator_Form_Entry_Model $entry - the entry model.
     * @param int $form_id - the form id.
     * @param array $field_data_array - the entry data.
     */
    do_action( 'forminator_custom_form_submit_before_set_fields', $entry, self::$module_id, self::$info['field_data_array'] );

    A simple way to see the data is to set the form to Page reload instead of submission ajax and use:

    <?php
    
    add_action('forminator_custom_form_submit_before_set_fields', function( $entry, $form_id, $field_data_array ) { 
    
    echo '<pre>';
    
    print_r($field_data_array);
    
    echo '</pre>';
    
    exit;
    
    }, 10, 3);

    Let is know if you have any additional questions.
    Best Regards
    Patrick Freitas

    Thread Starter gareth94

    (@atebol)

    Thank you for your reply @wpmudevsupport12 ?? Just to double check, there would be no way of doing it and keeping the submission to reload via ajax? Also how can I extract the field values from the $field_data_array? For example, if the user created 3 field groups on the form, how can I retrieve the values and store them to an external database? Thanks again for your help ??

    Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @atebol !

    I hope you’re doing well!

    Just to double check, there would be no way of doing it and keeping the submission to reload via ajax?

    In this case Patrick was referring to testing only, once you see the data you can then change back to Ajax mode. The reload is there only so you can see the output of the print_r() function while writing the code.

    Also how can I extract the field values from the $field_data_array? For example, if the user created 3 field groups on the form, how can I retrieve the values

    For this you need to initially use the print_r() function so you can see how the data is added in the $field_data_array and extract it using the standard PHP array syntax. print_r displays the raw data stored in a variable: https://www.php.net/manual/en/function.print-r.php

    store them to an external database?

    I’m afraid this part will be out of scope of the free support we can provide, for this you’ll need to write the code to match it to the setup you have or hire a developer.

    Best regards,
    Pawel

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @atebol,

    Since we haven’t heard from you for a while. I’ll mark this thread as resolved for now. Please feel free to re-open the thread if you need further assistance.

    Best Regards
    Nithin

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to iterate through ‘Field Group’ fields on submission’ is closed to new replies.