Hi guys,
i thought that i solved it, but i found a problem with disable possibility to create new parent and add new child by users when i follow the code from my previsou ticket:
https://toolset.com/forums/topic/hide-parent-taxonomy-in-cred-form/
When i set .remove - my users in CRED form are not able to create new child under the parent. They can only create new parent.
When i set .hide- my users in CRED form are still able to check the parent.
I would like to allow them to add new parent and new child, but i wouldnt allow them to check the parent.
You can check here:
-> first blue box - FIremní profil -> in the bottom of CRED form are checkboxes called - Jaké výrobce nabízíte?
I set code for:
Jaké výrobce..?
jQuery(document).ready(function(){
jQuery('.wpt-form-set.wpt-form-set-checkboxes-vyrobce > li > label > input.checkbox').attr('disabled','disabled');
});
// this allow user to check only 3 checkboxes
jQuery(document).ready(function ($) {
$("input[name='vyrobce[]']").click(function(e) {
var bol = $("input[name='vyrobce[]']:checked").length >= 3;
$("input[name='vyrobce[]']").not(":checked").attr("disabled",bol);
});
});
This works until user checks the first child...then something happen and the users are able to check parent.
I dont care if the checkbox of parent will be visible, but i would like to dont allow user to check the parent. They will be able to create new one (and of course child), but without possibility to check the parent.
Thank you for your support.
Hello,
I have edited your post to hide the credentials, it is not safe to share the credentials publicly, and the credentials you provided is not an administrator account, since it is a custom codes problem, please provide a valid administrator account, I need to test and debug it in a live website, thanks
Thanks for the details, I have modified your JS codes as below:
jQuery(document).ready(function ($) {
$("input[name='vyrobce[]']").change(function(e) {
var bol = $("input[name='vyrobce[]']:checked").length >= 3;
$("input[name='vyrobce[]']").not(":checked").attr("disabled",bol);
$('.wpt-form-set.wpt-form-set-checkboxes-vyrobce > li > label > input.checkbox').attr('disabled','disabled');
});
});
Please test again, check if it is what you want, thanks
Hi Luo,
its strange.... i´m still able select parent checkbox only for first. For example: when you select the child as a first item you cannot select the parent. If you select the parent first you cannot unselect this one. 🙂
You can look here (as a admin): hidden link
Anyway we can solve it easily in a different way - could you share with me code for automaticlly select the parent if user select the child? This will be maybe easier and for my solution is enough. I found this and im trying to parse it to my form without succes:
jQuery(document).ready(function($){
synchronize_child_and_parent_category($);
});
function synchronize_child_and_parent_category($) {
$("input[name='vyrobce[]']").find('input').each(function(index, input) {
$(input).bind('change', function() {
var checkbox = $(this);
var is_checked = $(checkbox).is(':checked');
if(is_checked) {
$(checkbox).parents('li').children('label').children('input').attr('checked', 'checked');
} else {
$(checkbox).parentsUntil('ul').find('input').removeAttr('checked');
}
});
});
}
Thank you for your help
1) I can not see the Toolset form as an admin user:
hidden link
2) For the question:
i´m still able select parent checkbox only for first
You just need to disable those parent checkbox options, for example, edit the post form: Form for Řešení Placeny
hidden link
Change the JS codes from:
jQuery(document).ready(function ($) {
To:
jQuery(document).ready(function ($) {
$('.wpt-form-set.wpt-form-set-checkboxes-vyrobce > li > label > input.checkbox').attr('disabled','disabled');
For the other new questions:
could you share with me code for automaticlly select the parent if user select the child?
It is a new question, there isn't such kind of built-in feature within Toolset Views plugin, it needs other custom JS codes, you will need to setup JS codes, and do these:
When click on a child checkbox, find it's parent checkbox option, and enable it
If you need more assistance for it, please create a new ticket for it, we prefer one ticket one question, thanks
My issue is resolved now. Thank you!