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%