Skip Navigation

[Resolved] How to add placeholder or first select option for post form drop downs?

This support ticket is created 4 years, 8 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 4 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#1322601
Screen Shot 2019-08-22 at 7.32.31 PM.png

I'm trying to create a blank select option for drop down fields in a CRED from the says "Choose your [field_name]" instead of the default --not set--

Is is possible?

#1322825

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Dallin

This is actually harder than it should be, and the first thing I'd do is recommend you submit a request for it to be possible to set alternate option labels when nothing is selected in the UI itself where you insert the field: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

It can be done, but requires some—simple—coding, so add a new snippet for this at Toolset > Settings > Custom Code.

The following is an example where I am changing the label for a couple of select fields which is simple enough that you should be able to see what I'm doing. Note that Types fields use a wpcf- prefix, so my "Assignee" field is referenced with wpcf-assignee, etc.

function ts_update_notset( $not_set_value, $attributes, $data ){

    if ( $data['name'] == 'wpcf-assignee' ) {
        $not_set_value['#title'] = '-- Choose Assignee --';
    }

    if ( $data['name'] == 'wpcf-priority' ) {
        $not_set_value['#title'] = '-- Set Priority --';
    }

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

Can you try that?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.