Problem:
A Toolset Form includes repeating fields where the user can add additional instances of the field. Client wants to limit how many instances of the field can be added, in such a way that the same technique (with different limits) can be used on multiple fields.
Solution:
A simple solution is to use a little custom JavaScript which hides the "Add New" button once the relevant number of instances has been added.
To be able to target different fields with different limits, add a class to the div wrapping the form field, something like this, where the class 'limit-to-3' is added:
<div class="form-group limit-to-3"> <label>Owner</label> [cred_field field="owner" force_type="field" class="form-control" output="bootstrap"] </div>
You can then use custom JS like so:
jQuery(function($) { $(".limit-to-3 .js-wpt-repadd").click(function(event) { $length = this.parentNode.childNodes.length; if ($length >= 5) { $(this).hide(); } }); });
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)
Dieses Thema enthält 4 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von vor 6 Jahren, 1 Monat.
Assistiert von: Nigel.