How to use array input in the attribute
petrozavodsky opened this issue · comments
I need to use an array in the name attribute, but instead I get an exception.
Component name must be non-empty alphanumeric string (see throw)
for example:
$form = new Nette\Forms\Form;
$form->addText('tags[1]', 'Tag 1:');
$form->addText('tags[2]', 'Tag 2:');
echo $form;
Can I use input arrays, and how do I do that ?
How about this?
$container = $form->addContainer('tags');
$container->addText('1', 'Tag 1:');
...
Please use forum for questions next time :)
Why forum? It's a html forms feature which is not supported (or maybe just not documented) by high-level api of nette/forms.
It could be used with manual rendering and getHttpData()
but it's not ideal
It fits.
$container = $form->addContainer('tags');
$container->addText('1', 'Tag 1:');
thank you very much
@mabar Forum is supposed to be the place where to ask questions. At least that's what DG always suggests. The feature is supported, but as you said, not explicitly documented here https://doc.nette.org/cs/2.4/form-fields#toc-addcontainer.