Hi there @matlino
Would you mind sharing the code you’re trying to use to get this to work?
If it’s a lot, maybe add as a gist and paste a link here. Or upload as a text file to Dropbox or Google Drive maybe and share the download link.
We’ll have a look for you and see if we can help get this working for you. 🙂
Cheers!
Patrick
Hi @wpmudevsupport16 ,
it’s a really simple use case. For example, I try to update the entry of another form inside ‘forminator_custom_form_submit_before_set_fields’ hook. If the field names I want to update (e.g. text-3) are the same I can just use $field_data_array directly to update the entry of another form successfully.
add_action('forminator_custom_form_submit_before_set_fields', function($entry, $form_id, $field_data_array) {
Forminator_API::update_form_entry( FORM_ID, ENTRY_ID, $field_data_array );
}
But it doesn’t work with select fields. It also doesn’t work when I create $entry_meta as in docs https://premium.wpmudev.org/docs/api-plugin-development/forminator-api-docs/. I try to extract values from both $entry and $field_data_array but if I remember correctly they are in the same format. Anyway, neither one is working.
I couldn’t update the value of a select field in any way. Although, I am able to update the values of other fields.
Tomas
-
This reply was modified 5 years, 3 months ago by
matlino.
Hi @matlino
I’ve consulted it with our developers and it’s mostly a matter of “data structure”. To update multi-select type fields, you’d need to use an array within array like in this example:
$field_data_array = array(
array(
'name' => 'select-1',
'value' => json_encode(
array(
0 => 'apple',
1 => 'orange'
)
)
)
)
I hope that helps!
Best regards,
Adam
Hello @matlino ,
We haven’t heard from you for a while now, so it looks like you don’t have more questions for us.
Please feel free to re-open this ticket if needed.
kind regards,
Kasia
Hello @wpmudev-support2 ,
I am sorry for the delayed answer. It’s working based on your example.
For everybody else having this use case, it seems ‘json_encode’ did the trick. That’s why you cannot just copy the value from $field_data_array or use $field_data_array as an argument to ‘update_form_entry’ API method.
Thank you for your help,
Tomas