From cad01a5a0f3bc401751e672b281f416ff1c374f3 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 8bc003240..ddf573e20 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 fbd76b4bf..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 ' - - -'; - $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; - echo ' -global->forms->item('sex')->getLabelPart())->attributes() /* line %d% */; - echo '>'; - echo $ʟ_elem->getHtml() /* line %d% */; - echo ' -global->forms->item('username')->getControlPart())->attributes() /* line %d% */; - echo '> -'; - /* line %d% */; - $this->global->forms->end(); %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}