Note: This is still EXPERIMENTAL.
This is an EXAMPLE.
Changes are very likely to occur.
It will not work on all rendered repeatables (requires wrapper with id).
It is strongly suggested that you make your own role if you use it.
Then you can modify it as needed.
You almost certainly want to do something else.
in order to position the new elements. Use the Bootstrap wrapper or the
controls_div tag on the Simple wrapper.
A role to be used in a Form Class:
This contains one method, render_repeatable_js. Its designed to be
used in a template, something like:
[% WRAPPER "wrapper.tt" %]
[% form.render_repeatable_js %]
<h1>Editing Object .... </h1>
[% form.render %]
[% END -%]
and setting the setup_for_js flag in the Repeatable field to add
the ability to dynamically add a new repeatable element in a form.
Note: this code is provided as an example. You may need to write your
Some of the extra information (level) in this function is in preparation for
handling nested repeatables, but its not supported yet.
This function operates on HTML elements that have the id of the
repeatable element. That requires that the wrapper have the repeatable
instance ID (now rendered by default). If you dont have wrappers around
your repeatable elements, this wont work.
See HTML::FormHandler::Field::AddElement for an example of rendering
an HTML element that can be used to provide the AddElement button.
See that field for the requirements for the add HTML.
See HTML::FormHandler::Field::RmElement for an example of rendering
an HTML element that can be used to provide a remove button.
See that field for the requirements for the remove HTML.