Skip to content

Commit 8bc8932

Browse files
committed
Collection: Add Docs
1 parent 5f10b93 commit 8bc8932

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/FormElement/Collection.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@
44

55
use ipl\Html\Attributes;
66

7+
/**
8+
* Collection can be used for creating dynamic forms or elements by describing a template which
9+
* will create as many iteration as provided in `populate()`.
10+
*
11+
* Example:
12+
* ```php
13+
* $collection = new Collection('testCollection');
14+
*
15+
* $collection->setAddElement('add_element', [
16+
* 'required' => false,
17+
* 'label' => 'Add Trigger',
18+
* 'options' => [null => 'Please choose', 'first' => 'First Option'],
19+
* 'class' => 'autosubmit'
20+
* ]);
21+
*
22+
* $collection->onAssembleGroup(function ($group, $addElement, $removeElement) {
23+
* $group->addElement($addElement);
24+
* $group->addElement('input', 'test_input');
25+
* });
26+
*
27+
* $form
28+
* ->registerElement($collection)
29+
* ->addHtml($collection)
30+
* ```
31+
*/
732
class Collection extends FieldsetElement
833
{
934
protected const GROUP_CSS_CLASS = 'form-element-collection';

0 commit comments

Comments
 (0)