File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# de.mysterycode.wcf.formBuilder.extension
22
3+ # Nested form fields
4+ Sometimes you want to store some data serialzed as an array but you want to have a form field for every property.
5+
6+ The form builder introduced in WSC 5.2 is currently not able to handle this case properly, so there is some sort of workaround required.
7+
8+ Usage example:
9+ ``` PHP
10+ use wcf\system\form\builder\container\DummyFormContainer;
11+ use wcf\system\form\builder\container\FormContainer;
12+ use wcf\system\form\builder\data\processor\PrefixedFormDataProcessor;
13+ use wcf\system\form\builder\NestedFormDocument;
14+ use wcf\system\form\builder\field\TextFormField;
15+
16+ $this->form = NestedFormDocument::create('DummyAdd');
17+ $this->form->appendChildren([
18+ DummyFormContainer::create('additionalData')
19+ ->appendChildren([
20+ FormContainer::create('foo')
21+ ->label('wcf.dummy.foo')
22+ ->appendChildren([
23+ TextFormField::create('additionalData[foo][bar]')
24+ ->label('wcf.dummy.foo.bar')
25+ ])
26+ ])
27+ ]);
28+ $this->form->getDataHandler()->addProcessor(new PrefixedFormDataProcessor('additionalData', 'additionalData'));
29+ ```
30+
31+ ###Attention:
32+ You have to serialize the array manually before writing it to your database!
You can’t perform that action at this time.
0 commit comments