Skip Navigation

[Resolved] CRED form with conditional fields based on dropdown lift

This support ticket is created 5 years 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 5 years ago.

Assisted by: Waqar.

Author
Posts
#1420781

Tell us what you are trying to do?

I want to create one custom form to add multiple products types. Depending on the selected product type (available as a dropdown list in the form), extra product data fields should appear. I got it to work, using a workaround:

- I needed to use "expert mode", because the dropdown (taxonomy) field is not listed in the GUI for building the conditional block. Also, if the fields are added inside the conditional block using the visual editor before switching to "expert mode", all elements inside the block are not visible in the "expert editor". So I added all elements in "GUI mode" but without moving the fields into the conditional block, then switched to "expert mode" and made all modifications and copy / paste

- the "if" condition needs to get the numerical "value" data for the option which is chosen from the dropdown, it cannot use the text. The only way to know the value is to go into "debugging mode" and look at the HTML to find the corresponding "value" data for the dropdown list options

[cred_show_group if="( $(producttype) eq 27 )" mode="fade-slide"] ... [/cred_show_group]

- options of the dropdown list appears in alphabetical order. In the taxonomy I created a "ranking" datafield to create an "order by" statement

-> it would be nice be able to use a custom query to populate the dropdown list to address all of the above remarks. Is it possible to tweak following code:

[cred_field field='producttype' force_type='taxonomy' output='bootstrap' display='select' single_select='true']

Is there any documentation that you are following?
- https://toolset.com/learn/create-an-ecommerce-wordpress-site/how-to-create-a-front-end-form-for-adding-woocommerce-products/

Is there a similar example that we can see?
- no

What is the link to your site?
- not available yet

thanks,
Ken

#1421837

Hi Ken,

Thank you for contacting us and I'd be happy to assist.

As mentioned in the documentation, the "cred_field" shortcode can be used to order the list either by "title" or "date":
https://toolset.com/documentation/user-guides/front-end-forms/cred-shortcodes/#cred_field

To generate the list using some different ordering criteria, you can use a taxonomy view that populates the options of a generic field ( ref: https://toolset.com/documentation/user-guides/front-end-forms/cred-shortcodes/#cred_generic_field ), since in views we can control the ordering through more fields.

The steps for this would be very similar to what I've suggested in another reply, recently:
https://toolset.com/forums/topic/cred-form-with-select-woocommerce-order/#post-1421231

The only difference would be that you'll be using the taxonomy view instead of a post view and for labels and values, you'll be using term titles and IDs.

Once the form submits, you can process the value of the selected option/taxonomy as needed, using the "cred_save_data" hook:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar