nette / forms

📝 Generating, validating and processing secure forms in PHP. Handy API, fully customizable, server & client side validation and mature design.

Home Page:https://doc.nette.org/forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automaticaly use macro formContainer from Container in foreach

h4kuna opened this issue · comments

If i prepare form with Container by $form->addContainer('foo'). In template i must use

{foreach $form->getComponent('foo')->getComponents() as $input}
	{formContainer $input}
		<input n:name="bar">
	{/formContainer}
{/foreach}

Is it possilbe in compile time use macro formContainer for foreach and $form->getComponent('foo')->getComponents() automaticaly? One level indent will be less.

Result is:

{foreach $form->getComponent('foo')->getComponents() as $input}
	<input n:name="bar">
{/foreach}

I know variable $form can to have other name.

If you agree and describe how resolve it, i will try prepare PR.

I don't really understand how it should work.

It's only idea, i'm not sure if is possible to implement.

You know if you have $form and on this instance, you can call getComponents() in this moment you want use macro {formContainer }. It is only my image.

I think it is not possible to implement and it brings a lot of magic. You can simply use <input n:name="$input">