Repeater Form Field: Add option to limit number of repeater items
A user has requested the ability to set a limit on the number of repeater items.
Hello, I've got the same issue, so I've looked on the code of SiteOrigin Widgets Plugin, and I add this feature myself. It's working well :) !
I've just add some code in two files to make it work :
-
base/inc/fields/repeater.class.php ====> I've created a new variable called "$max_items" to show or hide the "Add" button if we already have the setting number of repeater item (defined by $max_items in the widget).
-
base/js/admin.js ====> I've add some code to show or hide the Add button and duplicates buttons of repeater items when we add, delete or copy any repeater item, to make sure the user can't add more than ($max_item) items defined in the widget in the admin panel.
You can find my additionnal code in the two files I've attached to this comment. It could be great if you add this feature soon in the official deployed version of the plugin ! :) So I could keep this feature even if the plugin is updated !
so-widgets-bundle_feature_maxitems.zip
Thank you !
Hi @xella29 - would you be able to submit a pull request for the changes that you made so we can take a look?
Hello, it's done ! You can check it out now ! The code is quite simple, but it's working well and do the job :)