Skip to content

Commit

Permalink
Collection: Add Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
TAINCER committed Feb 27, 2023
1 parent 5f10b93 commit 8bc8932
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/FormElement/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@

use ipl\Html\Attributes;

/**
* Collection can be used for creating dynamic forms or elements by describing a template which
* will create as many iteration as provided in `populate()`.
*
* Example:
* ```php
* $collection = new Collection('testCollection');
*
* $collection->setAddElement('add_element', [
* 'required' => false,
* 'label' => 'Add Trigger',
* 'options' => [null => 'Please choose', 'first' => 'First Option'],
* 'class' => 'autosubmit'
* ]);
*
* $collection->onAssembleGroup(function ($group, $addElement, $removeElement) {
* $group->addElement($addElement);
* $group->addElement('input', 'test_input');
* });
*
* $form
* ->registerElement($collection)
* ->addHtml($collection)
* ```
*/
class Collection extends FieldsetElement
{
protected const GROUP_CSS_CLASS = 'form-element-collection';
Expand Down

0 comments on commit 8bc8932

Please sign in to comment.