Skip Navigation

[Resolved] How to display dependent dropdowns with views filter

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

Problem:
How to display dependent dropdowns with view's filter

Solution:
To know more and learn about how the "State" and "City" dependent drop-down setup, You can register test site on discover-wp.com to review how its setup and play with it. It’s totally free.
=> https://toolset.com/faq/how-and-why-to-create-a-test-site-in-discover-wp/

You can find proposed solution, in this case, with the following reply
https://toolset.com/forums/topic/conditional-logic-of-field/#post-901535

Relevant Documentation:
http://real-estate-wordpress.discover-wp.com/

This support ticket is created 6 years, 6 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
- 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 7 replies, has 2 voices.

Last updated by Minesh 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#900935

Hi,

I am trying to add custom post fields for custom Post Type called "CARS" that works like following when admin add a new "CARS Post":

1- Choose car Brand from Dropdown (Kia, Fiat, Audi, etc...)

2- After choosing a car Brand (e.g Kia) another dropdown with the Models of Kia will be shown (e.g Sportage, Sorento, Picanto, Niro, etc....)

3- After choosing a Model (e.g Niro) another dropdown with Versions of Niro will be shown (e.g Hybrid, Diesel, Benzine 1.6, etc...)

I tried to add this in CRED Generic field, this work fine. But i think this should be built from the beginning with a different way of (conditional Logic)

If you take a look at this website : hidden link
User can choose between New or Used cars, then they can choose Car Brand and then they can choose the specific models of a car Brand (but sure this is a search form not post submission)

What is the best way to make this correctly?

#901089

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

well - actually, dependent dropdown select is not supported with CRED, there is no such feature available using which you can build dependent dropdown and display it.

If you are agree, I can take it as a new feature request and send it for assessment to concern department.

#901111

Update:

Now the Conditional Display works fine in the post in wordpress dashboard. but i have another question.

I have one custom dropdown field of Car brands (e.g Kia, Mercedes, Jeep, Toyota, etc...) and its slug name is "car-brand"
After the admin choose a car-brand (e.g Kia) another dropdown show up with the slug name "car-models" . All MODELS of Car Brands are listed in "car-models" (e.g Sportage, Benz, Cherokee, Corolla, etc... ) but i want that the admin choose related models of Kia only when he choose kia, and not all models of other car brands.

can i do this with one custom field ONLY like "car-models" and show only related models of what admin choose in car-brand, or i need to create custom post field for every Car Brand with the related models o fit? for example this would look like this:

1- i will choose Kia from "car-brand"
2- "kia-models" show up with related kia models

but then i will have to create 50 custom fields for Car models and not only one custom field with all models of all car brand.

I would like to have this:

1- chose Kia from "car-brand"
2- show ONLY Kia's Models (Niro, sportage, Picanto, Rio) from "car-models"
3- then i would like to show ONLY Niro's Versions ( Hybrid, Benzin 1.6, Diesel) from "car-versions"

I prefer this way because i dont want to create 50 new fields and get 50 slug-names. Then i need also to add all 50 field slugs in my content template

If this is not possible with dropdowns (checkboxes, radios etc.. would work)?

also if the way i am thinking and trying to achieve this is wrong, then what would be the best to achieve this?

#901133

Minesh
Supporter

Languages: English (English )

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

I understand your requirement but there is no way to filter the dependent dropdowns or even if you set as checkboxes there is no way to filter the dependent custom fields.

Unfortunately there is no such feature available with Toolset to build dependent dropdowns in admin or with CRED forms.

You should try to handle this implementation using some custom programming or try to search for a plugin that may fulfill your needs. If you need custom programming for your project, please feel free to contact our certified partners:
=> https://toolset.com/contractors/

#901156

Ok i understand. PLEASE GUYS solve this in the future, I hope this will be added in the feature as an optiont. it will save us many hours and it will be with less work with code!

I have one more question from other Ticket that you have solved today morning about Title from different custom fields here: https://toolset.com/forums/topic/post-title-from-different-type-fields-not-working-with-cred/#post-900292

Now that i know i need to have 50-100 more fields is it still possible to create post Title created with Cred from all these fields for example:


add_action('cred_save_data', 'build_post_title', 10, 2);
function build_post_title($post_id, $form_data) {
  
if ($form_data['id']==2968) {
 
$field1 = get_post_meta($post_id, 'wpcf-car-manufacturer', true);
$field2 = get_post_meta($post_id, 'wpcf-model-year', true);
$field3 = get_post_meta($post_id, 'wpcf-kia-models', true);
$field4 = get_post_meta($post_id, 'wpcf-mercedes-models', true);
$field5 = get_post_meta($post_id, 'wpcf-toyota-models', true);
$field6 = get_post_meta($post_id, 'wpcf-jeep-models', true);
$field7 = get_post_meta($post_id, 'wpcf-bmw-models', true);
$field8 = get_post_meta($post_id, 'wpcf-hyundai-models', true);
$field9 = get_post_meta($post_id, 'wpcf-mazda-models', true);
$field10 = get_post_meta($post_id, 'wpcf-abarth-models', true);
$field11 = get_post_meta($post_id, 'wpcf-kia-sportage-versions', true);
$field12 = get_post_meta($post_id, 'wpcf-kia-niro-versions', true);
$field13 = get_post_meta($post_id, 'wpcf-kia-picanto-versions', true);
$field14 = get_post_meta($post_id, 'wpcf-kia-soul-versions', true);
$field15 = get_post_meta($post_id, 'wpcf-kia-rio-versions', true);
$field16 = get_post_meta($post_id, 'wpcf-mercedes-500-versions', true);
$field17 = get_post_meta($post_id, 'wpcf-mercedes-600-versions', true);
$field18 = get_post_meta($post_id, 'wpcf-mercedes-ls-versions', true);
$field19 = get_post_meta($post_id, 'wpcf-mercedes-800s-versions', true);
$field20 = get_post_meta($post_id, 'wpcf-toyota-corolla-versions', true);
$field21 = get_post_meta($post_id, 'wpcf-toyota-asti-versions', true);
$field22 = get_post_meta($post_id, 'wpcf-toyota-yaris-versions', true);
   
$post_title=$field1.'-'.$field2.'-'.$field3.'-'.$field4.'-'.$field5.'-'.$field6.'-'.$field7.'-'.$field8.'-'.$field9.'-'.$field10.'-'.$field11.'-'.$field12.'-'.$field13.'-'.$field14.'-'.$field15.'-'.$field16.'-'.$field17.'-'.$field18.'-'.$field19.'-'.$field20.'-'.$field21.'-'.$field22;
 
$slug = sanitize_title($post_title);
wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title,'post_name' => $slug));
}
}

Is this possible this way ?will this be ok or maybe this will cause me a problem in the future?

#901217

Another Question.

I am trying to show the filters conditionally in the Search form in views. Is that possible?

If a user in the search form choose Car Brand = Kia
Kia models with the dropdown will show up


[wpv-filter-start hide="false"]
[wpv-filter-controls]


<div class="price-dropdowns">
	[wpv-control-postmeta field="wpcf-car-brand" type="select" url_param="wpv-wpcf-car-brand" class="dropdown-box"]
</div>

[wpv-conditional if="( $(wpcf-car-brand).id(0km) eq 'kia' )"]<div class="form-group">
	<label>[wpml-string context="wpv-views"]דגם רכב[/wpml-string]</label>
	[wpv-control-postmeta field="wpcf-car-model" url_param="wpv-wpcf-car-model"]
</div>[/wpv-conditional]


[/wpv-filter-controls]
[wpv-filter-end]

I tired this but this isnt working with the conditional output!! Is there a waz to do this?

#901263

Please take a look at this search examples and let me know if its possible to make something like this with toolset.

1- hidden link If the user select one choice from "Select Maker" then he will be able to select "Select Model"

2- hidden link If user select one choice from "Select Make" he will be able to select "Select Model".

3- hidden link If the user choose one choice from "Make" then "Models" field will update

If this is not possible and it requires custom code could you please send me an instruction to follow or a code that i can use to make this happens and what is the best way to do it!

#901535

Minesh
Supporter

Languages: English (English )

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

Well - its possible but with view's and another thing is that you need to define make, modal etc.. etc.. as custom post type.

To implement such functionality - You should check this example:
=> hidden link
- Please check “State” and “City” dropdowns with search form.

To know more and learn about how the "State" and "City" drop-down setup, You can register test site on discover-wp.com to review how its setup and play with it. It’s totally free.
=> https://toolset.com/faq/how-and-why-to-create-a-test-site-in-discover-wp/

Additionally, please kindly open a new ticket with your each new question. This will help other users searching on the forum. Thank you for understanding.