diff --git a/src/Bridges/FormsLatte/FormMacros.php b/src/Bridges/FormsLatte/FormMacros.php index 27308efea..33f6155f1 100644 --- a/src/Bridges/FormsLatte/FormMacros.php +++ b/src/Bridges/FormsLatte/FormMacros.php @@ -165,11 +165,14 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer) $node->empty = $tagName === 'input'; if ($tagName === 'form') { + $node->openingCode = $writer->write( + 'global->formsStack[] = ' + . ($name[0] === '$' ? 'is_object(%0.word) ? %0.word : ' : '') + . '$this->global->uiControl[%0.word]; ?>', + $name + ); return $writer->write( - 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = ' - . ($name[0] === '$' ? 'is_object(%0.word) ? %0.word : ' : '') - . '$this->global->uiControl[%0.word], %1.var, FALSE)', - $name, + 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), %0.var, FALSE)', array_fill_keys(array_keys($node->htmlNode->attrs), NULL) ); } else { diff --git a/tests/Forms.Latte/expected/FormMacros.button.phtml b/tests/Forms.Latte/expected/FormMacros.button.phtml index eaef637ad..d0ae64375 100644 --- a/tests/Forms.Latte/expected/FormMacros.button.phtml +++ b/tests/Forms.Latte/expected/FormMacros.button.phtml @@ -6,8 +6,10 @@ class Template%a% extends Latte\Runtime\Template function render() { -%A%global->formsStack[] = $this->global->uiControl["myForm"], array ( +%A% + $form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"]; + ?>global->formsStack), array ( ), FALSE) ?>> global->formsStack)["send"]; diff --git a/tests/Forms.Latte/expected/FormMacros.forms.phtml b/tests/Forms.Latte/expected/FormMacros.forms.phtml index 5b2582744..fafbf79ac 100644 --- a/tests/Forms.Latte/expected/FormMacros.forms.phtml +++ b/tests/Forms.Latte/expected/FormMacros.forms.phtml @@ -191,9 +191,10 @@ class Template%a% extends Latte\Runtime\Template global->formsStack[] = $this->global->uiControl["myForm"]; if (1) { ?>
global->formsStack[] = $this->global->uiControl["myForm"], array ( + echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), array ( 'id' => NULL, 'class' => NULL, ), FALSE) ?>> @@ -208,8 +209,10 @@ class Template%a% extends Latte\Runtime\Template ?> -global->formsStack[] = is_object($this->global->uiControl['myForm']) ? $this->global->uiControl['myForm'] : $this->global->uiControl[$this->global->uiControl['myForm']], array ( +global->formsStack[] = is_object($this->global->uiControl['myForm']) ? $this->global->uiControl['myForm'] : $this->global->uiControl[$this->global->uiControl['myForm']]; + ?>global->formsStack), array ( ), FALSE) ?>> global->formsStack)["username"]; diff --git a/tests/Forms.Latte/expected/FormMacros.get.phtml b/tests/Forms.Latte/expected/FormMacros.get.phtml index c0cf09a61..0177902d6 100644 --- a/tests/Forms.Latte/expected/FormMacros.get.phtml +++ b/tests/Forms.Latte/expected/FormMacros.get.phtml @@ -5,8 +5,10 @@ ?> -global->formsStack[] = $this->global->uiControl["myForm"], array ( +global->formsStack[] = $this->global->uiControl["myForm"]; + ?>global->formsStack), array ( ), FALSE) ?>> global->formsStack), FALSE);