Problem:
A CRED form includes a repetitive field for images. The client wants to limit how many images the user can upload.
Solution:
This is not possible with Toolset settings and requires writing custom code, specifically jQuery in this case.
A possible solution would be the following, though you may need to modify it for your own use.
( function( $ ) { $( document ).ready( function(){ let maxreps = 4; $(".js-wpt-repadd").on( "click", function(e){ // how many repetitions? if ( $('.wpt-repctl').length >= maxreps -1 ) { // hide button to add more $(this).hide(); } }); // add click listener to trash buttons $(".click-form").on( "click", ".js-wpt-repdelete", function(e){ $(".js-wpt-repadd").show(); }); }); })( jQuery );
Add that to the custom JS section of the form, and edit for the maximum number of repetitions.
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 5 replies, has 3 voices.
Last updated by 6 years, 10 months ago.
Assisted by: Nigel.