Skip Navigation

[Closed] Updating A Form Field with 'cred_filter_field_before_add_to_form'

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 3 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1659155

Tell us what you are trying to do?
I am trying to modify the choices that are displayed on a form. I am trying to do this using a custom code snippet as conditional form inputs on the front-end work only for entire fields and not field options. With the below code, I am able to target the field for a specific form and modify the options; however, when I try testing the form the options are still the same. Is there a way to actually alter what displays on the form for example, remove a field option?

add_filter('cred_filter_field_before_add_to_form','form_display', 10, 1);
function form_display( $field) {
$form_html_id = $field['form_html_id'];
$parts = explode( '_', $form_html_id);
$form_id = (int) $parts[2];

if ($form_id == 34172){
if(in_array($field['id'], array('attendance-day-both-days'))){
$options = $field['data']['options'];
$end = count($options) - 1;
$finalOptions = array_slice($options, 0 ,$end);
$field['data']['options'] = $finalOptions;
return $field;
}

}

Thank you!

}

#1659817

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share more details. What is your field type you are trying to display on form. Is it select field or checkboxes field and what options you want to display?

The topic ‘[Closed] Updating A Form Field with 'cred_filter_field_before_add_to_form'’ is closed to new replies.