Tell us what you are trying to do?
Im trying to create a form for a repeatable field group but i need to limit the number of times that you can submit that for to 3, so you can only have 3 groups created
heres an example: i have a custom post called Studio each studio can only have 3 trainers (i set a repeatable group for trainer data inside studio) how can i limit to 3 trainers for each studio?
Hello and thank you for contacting the Toolset support.
Currently, the option to limit the number of items in an RFG is not supported. It will need custom code to be implemented.
You can implement a Javascript code to hide the button or disable the field when 3 items are added. And add a PHP code to validate the form and only allow 3 items in the RFG. Custom code in this previous thread may inspire you https://toolset.com/forums/topic/require-limit-number-of-repeating-field-group-entries/
I hope this helps. Let me know if you have any questions. Please provide a URL where we can see the form and screenshots when relevant.
I finally found out how to do it, I think there is a lack of support from you since I had to search through several threads to find the answers and they are never concrete answers
i use this code in the fucntions file
function train_count() {
$train_count = count( get_posts( array(
'post_type' => 'trainers',
'author' => get_current_user_id(),
) ) );
return $train_count;
}
then i register this function in toolset settings and use a conditional block to hide the form when $train_count = 3
thats it, im posting this solution in case anyone need it in the future.
My issue is resolved now. Thank you!
I finally found out how to do it, I think there is a lack of support from you since I had to search through several threads to find the answers and they are never concrete answers
i use this code in the fucntions file
function train_count() {
$train_count = count( get_posts( array(
'post_type' => 'trainers',
'author' => get_current_user_id(),
) ) );
return $train_count;
}
then i register this function in toolset settings and use a conditional block to hide the form when $train_count = 3
thats it, im posting this solution in case anyone need it in the future.