Should Forminator_CForm_Front_Action::maybe_handle_custom_option be adding an entry for “custom-select-1” to field_data_array which could then be read to get the actual value?
Hello @peter8nss
Hope you are doing well today.
I asked our developers to review your query, we will update you once we have further feedback.
Best Regards
Amin
Hello @peter8nss
We got further feedback from our developers.
This indicates that the value entered there is placeholder, but other options have values:
View post on imgur.com
If you want to change that behavior, you need to adjust the code and unfortunately, since custom coding is out scope of our support, 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 wpsupport@incsub.com.
Subject: ATTN: WPMU DEV support – wp.org”
Kind Regards,
Amin
I am an experienced developer.
When you have “other option” enabled for a select field you are right the field_data_array returns “custom_value” to tell you that the “Other” option has been selected. What it does not do is tell you what the value typed for that field was. Nor is that information included anywhere else in the field_data_array – which is surely an ommission. As result that information is unavailable in a number of crucial filters (e.g. forminator_custom_form_submit_before_set_fields) I wish to use to customize the form behaviour.
If I modify Forminator_CForm_Front_Action::maybe_handle_custom_option to remove the outer “if ( self::$is_draft ) {” it works as I would expect, including an additional entry in the field_data_array.
{
"name": "custom-select-1",
"value": "The text I entered for the other option"
}
Can that change please be incorporated in the code base or how else am I supposed to get the “other” value that was entered when processing the data in filter forminator_custom_form_submit_before_set_fields.
Hi @peter8nss ,
I hope you’re doing well, and thanks for sharing this further info.
I’ve forwarded the info to the Forminator developers and while I can’t promise that this is going to be implemented as it requires some discussion as well as development + QA tests, you can be sure that they will check your request.
Please let us know if you have additional questions.
Best Regards,
Williams Valerio
@peter8nss Please do not create duplicate topics again. It makes it harder for volunteers to support you. I have removed your new topic.
Please continue here.
I’m sorry about the duplicate post. However, I think it is important to note that I have now determined that the problem is wider than first identified and is not just confined to those writing code using apply_filters. Specifically, if you have select field with the “Other option” enabled, the text entered by a user for that other value is NOT stored in the submission at all.
Hello @peter8nss
If you could share an example, we can better understand your point. I will then provide the additional information to our forminator development team for further investigation.
Best Regards
Amin
I’ve done some further testing. What gets stored for the submission depends on the setting of “Default Stored Value”. If you have “Option values” selected, you get “custom_option” stored when an “other” value is entered. If you have “Option labels” selected, you do get the text entered for the other value stored for the submission. So the problem is limited to the fact that the entered value is not included in the field_data_array passed to the filters. [The original issue raised]
A (temporary) workaround for someone using forminator_custom_form_submit_before_set_fields is to access static Forminator_CForm_Front_Action::$prepared_data which does have the value for select-n available as custom-select-n.
Hi @peter8nss
We have informed our Forminator Team with all the details, and we have made an improvement task which will be implemented in future updates.
Kind Regards.
Kris