Skip Navigation

[Resolved] Maximum number of adding Images in Cred of specific repeating field

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

Problem:

I was wondering if there's a way to limit the number of instances in a repeating field. For instance, allow only 5 images uploads in a repeating field.

Solution:

There isn't such a built-in feature within Tooslet form plugin, it needs custom JS codes, here is an example:

https://toolset.com/forums/topic/maximum-number-of-adding-images-in-cred-of-specific-repeating-field/#post-1087340

Relevant Documentation:

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

Last updated by Furlan 6 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1084832
Hide-Add-new-after-5-pictures.jpg

Hi. I was wondering if there's a way to limit the number of instances in a repeating field. For instance, allow only 5 images uploads in a repeating field.

I tried with this solution https://toolset.com/forums/topic/minimum-maximum-number-of-adding-images-in-cred-of-specific-repeating-field/ but I can't achieve it to work.

#1085466

Hello,

There isn't such a built-in feature within Tooslet form plugin.

In the thread you mentioned above:
https://toolset.com/forums/topic/minimum-maximum-number-of-adding-images-in-cred-of-specific-repeating-field/#post-901992

Those custom codes does not work for the user too, so if you agree we can take it as a feature request, our developers will evaluate it.

If you are going to try custom codes, please provide a test site with the same problem, also point out the problem page URL and form URL, I need to test and debug it in a live website

#1087340

Thanks for the details, I can login your website, I assume we are talking about the Toolset post form "Nuevo Anuncio Gratis":
hidden link

In section "Content", click "JS Editor", the custom JS codes can not be saved correctly in your website, for example, you can input one single quote ' in it, and save the form, check it again, it is saved as \', this problem is abnormal, it might be a compatibility problem, I suggest you try to locate the problem plugin/theme.

As a workaround, you can move the custom JS codes into the wordpress page, I have tried these in your website:
1) Edit the form "Nuevo Anuncio Gratis", remove custom JS codes,
2) Move them into the page "Colocar Anuncio Gratis" content:
hidden link

<script type='text/javascript' class='custom-js'>jQuery(document).ready(function($){
$('.js-wpt-repadd').click(function( e ) {
        var length = $('input[type="file"]', $(this).closest('.js-wpt-field-items')).length; 
         if(length>=5) {
            $(this).hide();
         }
    });
});</script>

You can test it in the front-end:
hidden link

In the field "mágenes Adicionales", click link "Add new" 5 times, you should be able to see it is hiden when there is more than 5 instances.

#1087351

Hi Luo Yang,

Didn't know it was possible to add code directly on the page. It is working good. I replicated the same code in another page and it worked smoothly.

Thanks for you support.

Juan