Change — not set — label of select fields in Toolset Forms

The — not set — label for the first unselected option in a select field added to a Toolset Form cannot be changed in the UI, but can be changed with the following code that uses the wpt_field_not_set_option filter, like so:

/**
 * Replace the '--- not set ---' label of select fields in Toolset Forms
 */
function ts_update_notset( $not_set_value, $attributes, $data ){

    $labels = array();

    // Specify new labels for which select field, using wpcf- prefix and field slug
    $labels['wpcf-assignee'] = '-- Choose Assignee --';
    $labels['wpcf-priority'] = '-- Set Priority --';

    foreach ($labels as $key => $label) {

        if ( $key == $data['name'] ) {
            $not_set_value['#title'] = $label;
        }

    }

    return $not_set_value;
}
add_filter( 'wpt_field_not_set_option', 'ts_update_notset', 10, 3 );

Let us know if this snippet is not working for you:

This snippet doesn’t work
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments