Skip Navigation

[Resolved] CRED form select/select2 disable parent taxonomy field

This support ticket is created 6 years, 5 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
- 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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by magdalenaT 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#916126

Tell us what you are trying to do?

I need to disable possibility to select parent taxonomy:

hidden link

in select2 field called Wybierz miasto.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#916165

Hello,

I assume we are talking about the shortcode:
[cred_field field='fotograf-slubny' display='select' output='bootstrap']

There isn't such a built-in feature within Toolset form plugin, see our document:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
No such an option can achieve what you want:
disable possibility to select parent taxonomy

So it requires custom codes, since you are using select JS framework, I suggest you try to follow their document to disable those options:
hidden link

For your reference

#916351

Sory, but i dont have JS or JQuery skills, I think i understand this code. But i dont know how to revert it for my purpose

#916445

We don't provide such kind of custom codes support:
https://toolset.com/toolset-support-policy/

However, I can setup a demo for you, for example, you want to disable term "Kujawsko-pomorskie" ID 164 and term "Dolnośląskie" ID 160, you can modify the JS codes as below:

jQuery(document).ready(function() {
    jQuery("select[name='fotograf-slubny[]'] option[value=160]").attr('disabled', 'disabled');
    jQuery("select[name='fotograf-slubny[]'] option[value=164]").attr('disabled', 'disabled');
  ...

I have tested it in your website, it works fine, see the result page:
hidden link

More help:
hidden link

#916475

Thanks again Luo,

The code you gave morks great, i went 1 step further:

and took different value - as i see parent taxonomy have data-parent static and set to -1 so i dont need to create 10 or 15 queries. I have chanched code to this:

jQuery("select[name='fotograf-slubny[]'] option[data-parent=-1]").attr('disabled', 'disabled');

Maybe this will help someone with my problems and my lack of knowledge of coding