Skip Navigation

[Closed] Emptying taxonomies values in CRED

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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 6 replies, has 2 voices.

Last updated by Nigel 1 year, 3 months ago.

Assisted by: Nigel.

Author
Posts
#2625843

Tell us what you are trying to do?

I have a website that list accessibles locations accross the country. When someone register a new location, he can choose the country, provinces, regions and city, while using dropdowns for various taxonomies.

My problem is that if the user go straight to it's city, everything is fine. But if he changes is mind and switch province or country, the previou region / city are hiden of the page, but still enabled. So when the user sends the forms, I can either have new cities created in wrong taxonomies, or a location with multiple cities / provinces.

Is there a way to make sure all taxonomies values are empty (exempt ones trully selected) whe the user sends the form?

What is the link to your site?
hidden link

#2626041

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Catherine

From your other ticket I understand you are conditionally showing some of these inputs based on choices in other inputs.

To understand the problem better could you share the details of what is in your form editor so we can see how you have built the form and its conditions? I don't quite follow how it works currently.

#2626243

Hi Nigel,

Here is some parts of the code.
The "Pays" (country) taxonomy is always shown. Then, the "Province" part will switch from taxonomy A to B, depending the choice of the first one. Then, the third level (regions), will switch taxonomies #1 to #13, depending the choice of the second level taxonomy, and so on for the 4th level.

The thing is if I start with a specific 3rd and 4th level entry, and then I change the 3rd level entry, another 4th level taxonomy will show up. If I then select another 4th entry and submit the form, I end up with a post that may have #2 3rd level entry, #2 4rd level entry AND #1 4rd level entry enable in the good taxonomy, or create (same name) in the #2 4th level taxonomy.

I've ended up with a mess, having the same city created in many 4th level taxonomies, or a post with 2 4th level entries...

So I'm looking for a way to have ALL other taxonomies emptied, except the ones selected at the time of submission

That's a lot of code, but I don't know how to simplify. Also, my theme works with shortcode

<div class="cred-label">[wpml-string context="cred-lieu"]Ville et province[/wpml-string]</div>

[cred_field field='pays' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="pays_add_new" taxonomy="pays" type="add_new"]

[cred_show_group if="($(pays) eq '4005' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Province[/wpml-string]</div>
[cred_field field='ca-provinces' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[/cred_show_group]

[cred_show_group if="($(pays) eq '4004' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='fr-villes' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="fr-villes_add_new" taxonomy="fr-villes" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(pays) eq '4005' )" mode='fade-slide']
[cred_show_group if="($(ca-provinces) eq '3578' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Région administrative[/wpml-string]</div>
[cred_field field='region-qc' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3579' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='region-ab' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="region-ab_add_new" taxonomy="region-ab" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3585' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='region-cb' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="region-cb_add_new" taxonomy="region-cb" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3584' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='region-ipe' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="region-ipe_add_new" taxonomy="region-ipe" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3581' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='region-mb' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="region-mb_add_new" taxonomy="region-mb" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3582' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='region-nb' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="region-nb_add_new" taxonomy="region-nb" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3583' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='region-ne' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="region-ne_add_new" taxonomy="region-ne" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3577' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='region-on' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="region-on_add_new" taxonomy="region-on" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3580' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='region-sk' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="region-sk_add_new" taxonomy="region-sk" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3586' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville[/wpml-string]</div>
[cred_field field='region-tnl' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="region-tnl_add_new" taxonomy="region-tnl" type="add_new"]
[/cred_show_group]
[/cred_show_group]

[cred_show_group if="($(ca-provinces) eq '3578' )" mode='fade-slide']
[cred_show_group if="($(region-qc) eq '1481' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville et quartier[/wpml-string]</div>
[cred_field field='quartiers-abitibi' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="quartiers-abitibi_add_new" taxonomy="quartiers-abitibi" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(region-qc) eq '1580' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville et quartier[/wpml-string]</div>
[cred_field field='quartiers-bas-saint-laurent' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="quartiers-bas-saint-laurent_add_new" taxonomy="quartiers-bas-saint-laurent" type="add_new"]
[/cred_show_group]

[cred_show_group if="($(region-qc) eq '1498' )" mode='fade-slide']
<div class="cred-description">[wpml-string context="cred-logement"]Ville et quartier[/wpml-string]</div>
[cred_field field='quartiers-capitale-nationale' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
[cred_field field="quartiers-capitale-nationale_add_new" taxonomy="quartiers-capitale-nationale" type="add_new"]
[/cred_show_group]

(and so on for a total of 13 taxonomy in QC province, in Canada country)
[/cred_show_group]

#2626245
cbdallaire-bug-taxonomy-dropdown-value.JPG

Here is how it looks on the website form

#2626587

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Thanks for the details, it looks complex, but I see how you have this set up.

The thing is, the problem you describe shouldn't be happening.

Toolset Forms includes the functionality that if a form input is conditionally hidden, then when the form is submitted any fields within the hidden section (custom fields or taxonomies) are stripped and not submitted with the form.

But that doesn't appear to be working in your case (I just checked it is working on my local test site).

Could I get access to your site to check what is happening? (A staging server for testing would be better.)

Let me mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for us to use that you can later delete. And be sure to have a current backup of your site.

Can you also confirm where I can test the form?

#2628841

Hi Nigel,

I think I'll simply move to one-to-many post relationship, but I need to make tests. Can you keep this post open few more days?

Thanks!

#2629929

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

No problem, I'm just going to mark it as awaiting your feedback so that it is not sitting in my queue.

The topic ‘[Closed] Emptying taxonomies values in CRED’ is closed to new replies.