Using Forminator API to prepopulate field
-
Regarding the Forminator API, I’m using the free version, and are trying to update a hidden field in a form via the API which would then be used to prepopulate the behavior string, but no matter what I try, when it is submitted, the field does not show up in the behavior.
I want to redirect to a url using a variable, because the url changes. In behavior, I have:
https://www.forwardto.com/{hidden-4}?type={radio-2}
The “{radio-2}” variable works fine, as it is entered on the form. However, the {hidden-4} field is the tricky one. It needs to be populated via a variable that is not in the field initially, and I can’t bring it in via a url parameter.
Using the API, I’m accessing the variable from some userdata (website url). That works fine. Then, I’ve tried these things to update the hidden form field:
Forminator_API::update_form_field
Forminator_API::add_form_fieldLooking at the form data with
Forminator_API::get_form_fields_by_type( $form_id, 'hidden' )
…it looks like the data is being added to the field, but when the form is submitted, it doesn’t get recorded in the db, nor is it used by behavior.
I’ve also tried Forminator_API::update_form_entry, and that does get recorded in the db, but it apparently happens after the form submission, so it can’t get used in the form ‘behavior’.
How can this be accomplished? Any help would be appreciated.
- The topic ‘Using Forminator API to prepopulate field’ is closed to new replies.