Skip to content

Commit e5b920c

Browse files
committed
Latte: {formContext}, {formPrint} & {formClassPrint) are deprecated
1 parent 49b3de1 commit e5b920c

5 files changed

Lines changed: 8 additions & 30 deletions

File tree

src/Bridges/FormsLatte/Nodes/FormNode.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
/**
2121
* {form [scope|detached] name [, attributes]} ... {/form}
22-
* {formContext name} ... {/formContext}
2322
* Renders form tags and initializes form context.
2423
* The `scope` keyword makes {form} skip the <form> tag emission while still pushing the
2524
* form on the stack — semantically identical to {formContext}, but with the canonical
@@ -60,6 +59,9 @@ public static function create(Tag $tag): \Generator
6059
}
6160
$node->attributes = $tag->parser->parseArguments();
6261
$node->print = $tag->name === 'form' && $node->mode !== 'scope';
62+
if (!$node->print) {
63+
trigger_error('Tag {formContext} is deprecated', E_USER_DEPRECATED);
64+
}
6365

6466
[$node->content, $endTag] = yield;
6567
if ($endTag && $node->name instanceof StringNode) {

src/Bridges/FormsLatte/Nodes/FormPrintNode.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class FormPrintNode extends StatementNode
2626

2727
public static function create(Tag $tag): static
2828
{
29+
if ($tag->name === 'formPrint') {
30+
trigger_error('Tag {formPrint} is deprecated, use Nette\Forms\Blueprint::latte($form)', E_USER_DEPRECATED);
31+
} else {
32+
trigger_error('Tag {formClassPrint} is deprecated, use Nette\Forms\Blueprint::dataClass($form)', E_USER_DEPRECATED);
33+
}
2934
$node = new static;
3035
$node->name = $tag->parser->isEnd()
3136
? null

tests/Forms.Latte/expected/forms.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,3 @@
106106

107107
<select name="select" id="frm-select"><option value="m">male</option><option value="f">female</option></select>
108108
</form>
109-
110-
111-
112-
113-
<label>Sex:</label>
114-
<input type="text" name="username" class="control-class" id="frm-username">

tests/Forms.Latte/expected/forms.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -240,21 +240,4 @@
240240
';
241241
echo $this->global->forms->renderFormEnd() /* pos %d%:1 */;
242242
$this->global->forms->end();
243-
244-
echo '
245-
246-
247-
';
248-
$this->global->forms->begin($form = $this->global->uiControl['myForm']) /* pos %d%:1 */;
249-
echo '
250-
<label';
251-
echo ($ʟ_elem = $this->global->forms->item('sex')->getLabelPart())->attributes() /* pos %d%:8 */;
252-
echo '>';
253-
echo $ʟ_elem->getHtml() /* pos %d%:8 */;
254-
echo '</label>
255-
<input';
256-
echo ($ʟ_elem = $this->global->forms->item('username')->getControlPart())->attributes() /* pos %d%:8 */;
257-
echo '>
258-
';
259-
$this->global->forms->end();
260243
%A%

tests/Forms.Latte/templates/forms.latte

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,3 @@
7575

7676
<select n:name="select" />
7777
{/form}
78-
79-
80-
{formContext myForm}
81-
<label n:name="sex" />
82-
<input n:name=username>
83-
{/formContext myForm}

0 commit comments

Comments
 (0)