Skip Navigation

[Resolved] I really can't find a way to insert default value or place holder cred field

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 3 replies, has 2 voices.

Last updated by hernanL 4 months ago.

Assisted by: Minesh.

Author
Posts
#2708853

Hello,

I have difficulty with a taxonomy in form. In reality, this taxonomy could perfectly do without hierarchy (be like a label) but I have selected with hierarchy to have more flexibility in the form

But I still have problems, I would like this taxonomy to have a "select" format in the form, but I really can't set the placeholder or default value (both options are fine for me). I have already tried what appears in the official documentation, nothing seems to work or take effect (placeholder, value, select_text)

Can't this be done? Would I be forced to use JS?

Thanks greetings

#2708857

By the way, I use ajax forms, so that information is not lost if the user does not pass a validation

#2708990

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Yes - you will have to use the custom JS to set the first option for the taxonomy select field.

You can add the following custom JS code to your form's custom JS editor box:


jQuery(document).ready(function($){
  jQuery("select[name='book[]']").prepend('<option value="0">-choose-</option>');
  jQuery("select[name='book[]']")[0].selectedIndex = 0;
});

Where:
- change the book with your taxonomy slug.

#2709099

Thanks, it works, it even remembers the selected option if there is a validation problem. The only problem is that if the field is empty on ajax reload the placeholder disappears and the first available option is selected. It does not seem easy to solve since if we execute the code after an ajax load, what the user selected will be lost

Thanks for the option, I'll think about this a little more. But I am considering other paths, I think that the form will simply leave a text field, with the toolset filters I will work to add or create the terms of that taxonomy

Maybe in general you could consider improving that in the future, taxonomies in forms are not very flexible or have an interface that is too old for users (I am referring to taxonomies without hierarchy, for us it is normal to work with tags, but for the end user it's weird having to hit enter or click "add" to add a taxonomy)

I need to think a little more about this

#2709128

I have decided to place a generic custom field in the form, thanks for the option. Please consider feedback to perhaps have more flexibility in the future in this regard.

Thanks for the support