Radio button value not transferring via Formidable API

By: Andrew Christensen | Asked: 11/12/2024
ForumsCategory: General questionsRadio button value not transferring via Formidable API
Andrew Christensen asked 4 weeks ago
We have a network of sites. There's one main site that acts as the admin panel for the rest of the sites for an event post system.

So in the main site, I have a form with a bunch of fields. One of those fields is called "On Click Action" with 3 options:
"None", "Close Popup", "Redirect To"

The redirect radio button is an "other" option where the user can enter a URL for the action to send a visitor to when they click on the event post popup.

In the "sub sites" I have the exact same form (exported from the main site and imported to the sub sites). In the main site, in the settings I have it set to post the form contents to the sub sites.

In the main site AND in the sub sites, the key on the click action field is `smdvv`. On the main site the ID of the field is 162. So the config of the API post looks like the attached (screenshot1.jpg).

But, when the form was submitted, the site it was sent to had the default value of "None" selected and no URL entered. But the keys DO match. The value is correct. Is there something different I need to do in the config of the action to get the radio buttons value to transmit to the receiving end?  
Attachments
Andrew Christensen replied 4 weeks ago

I changed the action URL to a requestbin url and submitted the data to there to inspect the content. You can see the output here: https://snipboard.io/6leDLE.jpg

So the issue seems to be that the Formidable API functionality is receiving the value as the URL and not translating that to the other option.

Victor Font replied 4 weeks ago

That's a good guess, but it's not what's happening. The other field is actually not named 162 or 'smdvv'. In code it's referenced as 'other_2' and because it's a tack-on option to field 162, its full name in code is [162][other_2].

This is what I see in the database with a test field and only the other option populated:

a:1:{s:7:"other_2";s:17:"http://google.com";}

The reference is other_2. I don't know how you would reference the other field directly through the API, buy you could do something withe data in this hook: https://formidableforms.com/knowledgebase/frm_api_post_response/

Andrew Christensen replied 4 weeks ago

<p>Thank you Victor.</p><p> </p><p>I have to admit I'm a bit confused. Does this mean that on the receiving site I have to add one of these hooks that will update the record AFTER the api receives and writes it? I don't really understand how the hook would be used for this since what I'm seeing is very generic. I have no idea the body would look like and I have no way to output the body to something so I can debug it.</p><p> </p><p>Would the line $returned_id = $body["CHANGEME"];</p><p> </p><p>for me be something like:</p><p>$redirect_value = $body["smdvv"];</p><p>if (stristr($redirect_value,"http")) {</p><p>    // update record's other_2 value</p><p>}</p><p> </p><p>Trying to understand how to handle this.</p><p> </p><p>Thank you!</p>

Andrew Christensen replied 4 weeks ago

argh the editor on this forum sucks. It needs markup support.

Victor Font replied 4 weeks ago

This is the first time anyone has ever asked about populating the "other" field through the API. I only know that Formidable requires it to be saved as part of the serialized data returned for the input using the other field.

This means you have to specifically identify the values key-value pair with the key "other_2" otherwise it will never populate the other field. I have no time to dig into code to find a different way, but the only thing I can recommend now is to use the hook to retrieve the value intended for the other field and dress it as a serialized array and populate the field in frm_item_metas as you would to update any meta value programmatically.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right