I have a one to many post relationship - Venues and Events. One Venue can have many events
On a CRED form I want to add the event details and then select the venue. I don't like having the select box as it is by default, with the "search" section, and then waiting a few seconds for it to populate.
Is it possible to make the dropdown just a standard dropdown box? It would be nicer and cleaner for many purposes I believe and make it look more like an online app.
Hi, the default behavior here is to display a standard field if there are fewer than some preset number of parents, I think it's 15 or 16. If there are more possible parents, the searchable field is displayed. If you would like to prevent the searchable field from being displayed, you can add the attribute/value pair use_select2="never" to the field shortcode in the Form builder. Note that you must use the "expert mode" Form builder to add this attribute. Example:
[cred_field field='@book-chapter.parent' class='form-control' output='bootstrap' select_text='--- not set ---' use_select2='never']
Let me know if this does not solve the problem for you and I can take a closer look.
Thanks for that, it seems to work
Although it was showing the select2 version before with only 2 options/posts - which is way under the limit you mentioned
Okay I asked for some clarification and it turns out this use_select2 attribute should be avoided if possible. We recently made some changes to our documentation to reflect these changes, which you can find here: https://toolset.com/documentation/user-guides/front-end-forms/cred-shortcodes/#cred-field
If used with new post relationships (Types 3,0+), it breaks the "order", "ordering" and "author" attributes. It can also break background checks like what post type to display in the select field for relationships. We now include a warning: Do not use this attribute if not explicitly required.
If you wanted to create a standard select field instead of using the autosuggest-style input ( a feature provided by select2.js ), a custom solution is necessary. You would remove the cred_field shortcode for the post relationship from the Form, then add a generic select field. Using Views, you can provide the options for this select field using a specially formatted View of parent posts.
Then in order to actually connect the parent and child posts when the new post is created, you would use the cred_save_data API along with the toolset_connect_posts API. So the process for setting this up isn't simple, but I can point you to some sample code here on the site if you're interested in taking on the additional work to make the experience just like you want.