• Resolved Mick Tindall

    (@livewire1407)


    I have a form where a select box populates a list of certain types of users that have accounts on the site (using forminator_cform_render_fields – this works fine).

    I also have code in place that fills out other parts of the form when a user is selected (also working fine – forminator_render_form_markup)

    I’m having an issue when the form is submitted – validation issue on the select field “Selected value does not exist.”

    I’ve looked at other posts on this topic and implemented forminator_replace_form_data – but I’m either doing something wrong, or that isn’t the solution I need.

    Pastebin to form export – https://pastebin.com/mzsKqjKb

    Pastebin to back end code – https://pastebin.com/wTE8zwsN

    Any help would be appreciated. I just want the form to go through and save (I don’t care about if the user dropdwn value is saved or sent in the email etc – but I don’t know how to indicate that to forminator)

    • This topic was modified 3 years, 1 month ago by Mick Tindall.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @livewire1407,

    I hope you are keeping well today and thank you for reaching out to us.

    I have pinged our developers to review your code and we’ll update you here once we have more insights on what might be causing the issue.

    Kind Regards,
    Nebu John

    Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @livewire1407,

    Our developers have provided an update, and they have identified that your code is rendering only on the frontend, not the backend. To fix this, please replace the following code from your workaround,

    if (!empty($siteUsers)) {
                        $newOptions = [];
     
                        foreach($siteUsers as $user) {
                            $newOptions[] = [
                                'label' => $user->display_name,
                                'value' => $user->ID,
                                'limit' => '',
                                'key'   => forminator_unique_key()
                            ];
                        }
     
                        $wrappers[$wrapperKey]['fields'][0]['options'] = $newOptions;
                    }

    with the following,

    if (!empty($siteUsers)) {
                        $newOptions = [];
                        $user_names = array();
     
                        foreach($siteUsers as $user) {
                            $newOptions[] = [
                                'label' => $user->display_name,
                                'value' => $user->ID,
                                'limit' => '',
                                'key'   => forminator_unique_key()
                            ];
                            $user_names['options'] = $newOptions;
                        }
                        $select_field = Forminator_API::get_form_field( $formId, $wrapper['fields'][0]['element_id'], true );
                     if ( $select_field ) {
                         Forminator_API::update_form_field( $formId, $wrapper['fields'][0]['element_id'], $user_names );
                         $wrappers[ $wrapperKey ][ 'fields' ][ 0 ][ 'options' ] = $newOptions;
                         }
                      
                    }

    I hope that helps, please feel free to get back to us if you need any further assistance.

    Kind Regards,
    Nebu John

    Thread Starter Mick Tindall

    (@livewire1407)

    That worked! Thanks!

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hi @livewire1407

    Thank you for the update. Glad to hear Nebu’s help was useful!

    Feel free to let us know if you have any further issue or have any question about Forminator. The team will be glad to provide further assistance.

    Best Regards

    Luis

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Select custom options issue – Validation – Selected value does not exist’ is closed to new replies.