From e14e0b96fdcaf86cca0c40c948bca33c3813e47f Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 10 Nov 2023 14:06:48 +0100 Subject: [PATCH] Latte: {formContext}, {formPrint} & {formClassPrint) are deprecated --- src/Bridges/FormsLatte/Nodes/FormNode.php | 4 +++- src/Bridges/FormsLatte/Nodes/FormPrintNode.php | 5 +++++ tests/Forms.Latte3/expected/forms.html | 6 ------ tests/Forms.Latte3/expected/forms.php | 18 ------------------ tests/Forms.Latte3/templates/forms.latte | 6 ------ 5 files changed, 8 insertions(+), 31 deletions(-) diff --git a/src/Bridges/FormsLatte/Nodes/FormNode.php b/src/Bridges/FormsLatte/Nodes/FormNode.php index a3bf7dc62..612059b17 100644 --- a/src/Bridges/FormsLatte/Nodes/FormNode.php +++ b/src/Bridges/FormsLatte/Nodes/FormNode.php @@ -22,7 +22,6 @@ /** * {form name} ... {/form} - * {formContext ...} */ class FormNode extends StatementNode { @@ -47,6 +46,9 @@ public static function create(Tag $tag): \Generator $tag->parser->stream->tryConsume(','); $node->attributes = $tag->parser->parseArguments(); $node->print = $tag->name === 'form'; + if (!$node->print) { + trigger_error('Tag {formContext} is deprecated', E_USER_DEPRECATED); + } [$node->content, $endTag] = yield; $node->endLine = $endTag?->position; diff --git a/src/Bridges/FormsLatte/Nodes/FormPrintNode.php b/src/Bridges/FormsLatte/Nodes/FormPrintNode.php index 204e541d2..f1ff307e5 100644 --- a/src/Bridges/FormsLatte/Nodes/FormPrintNode.php +++ b/src/Bridges/FormsLatte/Nodes/FormPrintNode.php @@ -27,6 +27,11 @@ class FormPrintNode extends StatementNode public static function create(Tag $tag): static { + if ($tag->name === 'formPrint') { + trigger_error('Tag {formPrint} is deprecated, use Nette\Forms\Blueprint::latte($form)', E_USER_DEPRECATED); + } else { + trigger_error('Tag {formClassPrint} is deprecated, use Nette\Forms\Blueprint::dataClass($form)', E_USER_DEPRECATED); + } $node = new static; $node->name = $tag->parser->isEnd() ? null diff --git a/tests/Forms.Latte3/expected/forms.html b/tests/Forms.Latte3/expected/forms.html index f19f9c351..30672133c 100644 --- a/tests/Forms.Latte3/expected/forms.html +++ b/tests/Forms.Latte3/expected/forms.html @@ -111,9 +111,3 @@ - - - - - - \ No newline at end of file diff --git a/tests/Forms.Latte3/expected/forms.php b/tests/Forms.Latte3/expected/forms.php index 856c0d60e..1fea76c4f 100644 --- a/tests/Forms.Latte3/expected/forms.php +++ b/tests/Forms.Latte3/expected/forms.php @@ -257,22 +257,4 @@ '; echo $this->global->forms->renderFormEnd() /* line %d% */; $this->global->forms->end(); - - echo ' - - -'; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo ' -global)->getLabelPart())->attributes() /* line %d% */; - echo '>'; - echo $ʟ_elem->getHtml() /* line %d% */; - echo ' -global)->getControlPart())->attributes() /* line %d% */; - echo '> -'; - array_pop($this->global->formsStack) /* line %d% */; %A% diff --git a/tests/Forms.Latte3/templates/forms.latte b/tests/Forms.Latte3/templates/forms.latte index 7196558bc..91153dcfd 100644 --- a/tests/Forms.Latte3/templates/forms.latte +++ b/tests/Forms.Latte3/templates/forms.latte @@ -80,9 +80,3 @@ -{/formContext myForm}