Skip Navigation

[Resolved] How to create a single select field in Toolset

This thread is resolved. Here is a description of the problem and solution.

Problem:
How can we create single select fields (dropdown) in Toolset?

Solution:
The Field (Select) can be created in Toolset Types under Toolset > Custom Fields > Add new/Edit existing Group > Add New/Edit Existing Field.
There you can choose the type of the field to be added and save it.

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/#select

100% of people find this useful.

This support ticket is created 6 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by SteveWebStudioNW 6 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#619288

Tell us what you are trying to do?
------------------------------------------------
I have created a cred edit form with a select box that shows a set of options from a taxonomy, the 'Select' drop down box on the cred edit form never take into account which option has been saved in the post it just displays a list of what is in the taxonomy and does the set any item as 'selected' even though it is saved in the database.

Example
------------
If I have a bunch of taxamonies in a cred 'new post' form with a the select box showing the taxonomy, items for example.... options 1,2,3,4> I

f I select and save the option as '4' this saves into the database OK

When I come to edit the post, the select box is now displaying the first option and not the option that is saved when I created the post.

this is the select box in the cred form code i am using
[cred_field field='drop-zone' display='select' single_select="true" output='bootstrap']

I cant find any documentation how to tell the select box to set the selected item in the drop down to the option that has been set on post creation.

What is the link to your site?
hidden link

Many thanks!

#619370

I tested this locally and this is how it works:

1. If a Hierarchical Taxonomy is set to select single, single select true, then we obviously defy the purpose of a hierarchical taxonomy

2. But, we can do it and we will see a select dropdown populated with all existing terms, and if we choose one, the post will be updated with that term.

3. When you load a Post that has several terms set, it will obviously display just one, and that is why I mean that the purpose is defeated, it is not the correct information anymore eventually.

4. In any case, any term you save on the post is correctly reflected on the CRED form and each term updated will remove all old terms and add the new term only.

So far, I saw no issues.

But then, eventually, I miss a step or detail.

We do also have similar issues as you desccribe with checkboxes, maybe I misunderstood you, and you meant those:
https://toolset.com/forums/topic/cred-form-not-ticking-checkboxes/

Please let me know if I miss something to above steps.

#619924

Ah! so does that mean I should not use a taxonomy, all I need is a drop down select box with a single selection only. Can this be done with a taxonomy, and on an edit for it show me which selection has been saved in the post?

#619987

all I need is a drop down select box with a single selection only

Then I suggest a single Field (Select) to be created in Toolset Types first
https://toolset.com/documentation/customizing-sites-using-php/functions/#select

This will give you what you need here.

#620076

Yes I will do that instead, I a used taxonomy to make it more simple for a third party to add extra items, but using the standard select box will probably be easier in the long term to manipulate the data.

As always great support many thanks Beda!