• Resolved isisky

    (@isisky)


    Hello,

    I have a dynamically populated select field (receives ajax data depending on a previous select field selection) when submitting the form whatever the user selected on the field is not transmitted and does not appear in the entry next to the field on the back-end. I thought that might come from select2, or forminator only accepting previously set options in the backend, so I also tried to copy the select value and copy it to a normal text field, or a text area, in everycase anytime I try to populate a field using jquery, it seems, this field does not send is value to the form.

    This is the jquery code I’m using to set the value in the field, the value seems propely set to the input field as if i try to check them using console.log() it shows alright :

    $('#select-2 select').on('change', function() {

                var selectedText = $("#select-2 select option:selected").text();

                $('#text-3 input').val(selectedText);

            });

            $('#text-2 input').on('change', function() {

                var selectedVal = $("#text-2 input").val();

                $('#textarea-2 textarea').val(selectedVal);

            });

    I also tried changing form submitting from ajax to post without success, is there a proper way to interact with forminator in ajax that I am missing ?

    • This topic was modified 1 week, 3 days ago by isisky.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @isisky,

    Please check the API docs and see if that helps regarding this:
    https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/

    Filling the select field using JavaScript alone may not be effective if the same options are not available on the backend.

    A general approach is to use the update_form_field() method to update the field options on the backend. This ensures that the options are properly recognized by the form’s validation system. Identify the form and field IDs, and then generate dynamic options to update the form field accordingly.

    You can refer to this doc for more info:
    https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/#method-update_form_field

    Regards,

    Nithin

    Thread Starter isisky

    (@isisky)

    Thank you for you answer, that may explain why the select field is not working but why are the text field not working when I’m updating them with javascript? as they are supposed to be filled by the user so any input should be alright.

    I checked the api but if i update the select field using ajax, will it actually show in the front end? I thought the fields were populated on form loading so I will still have to manually update the select field myself in js ?
    Is there any documentation regarding the $data argument structure used in this methode :

    Forminator_API::update_form_field( 7, ’email-2′, $data?);

    Edit: I changed my approach, I’ve put every options already in the select field using the bulk import from the backend and I only hide the ones I don’t want to appear using jquery so that the options are still the original ones, only their visibility is toggled and still it does not get through in the submitted entries, it seems any javascript manipulation of a field automatically invalidate it.

    • This reply was modified 1 week, 3 days ago by isisky.
    • This reply was modified 1 week, 3 days ago by isisky.
    Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @isisky,

    We confirmed the code is working and the text field value is getting saved.

    For the select field dynamic options, as mentioned, you need to write code and use update_form_field to update the options in the backend as well.

    I’m afraid providing the exact code will be outside the scope of support we can provide. For that, you’ll need to hire a developer to provide the required custom code for you. WordPress provides a jobs directory here https://jobs.wordpress.net/

    If you need further advice about it, feel free to email us at [email protected] using the following subject.

    “Subject: ATTN: WPMU DEV support – wp.org”

    Best Regards,
    Nebu John

    Thread Starter isisky

    (@isisky)

    Hello, I can confirm the text field value is not getting saved, I can provide you access to the backend if you don’t beleive me, as fot the select field dynamic option as I explained in my answer this is already solved as I added all the options in the backend so no further custom code is required, it might be a bug with my form in that case is there any way to do some debugging ?
    I want to get the pro version to actually use the geo location feature, but filling form with javascript is a mandatory feature required for this form and if forminator does not support it I will have to switch to another plugin and avoid losing more time fiddling with this one.

    Best regards

    Thread Starter isisky

    (@isisky)

    I found the issue, on a multistep form, changing step actually trigger the on change jquery event for the select elements, probably when they are hidden fro screen, this is what was messing with my code. Thank you for the support, I’ll be getting the pro version now that it solved.

    Best regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.