Skip to content

Commit 08dc976

Browse files
committed
Latte: {formContext}, {formPrint} & {formClassPrint) are deprecated
1 parent 3cf4861 commit 08dc976

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
@@ -22,7 +22,6 @@
2222

2323
/**
2424
* {form name [, attributes]} ... {/form}
25-
* {formContext name} ... {/formContext}
2625
* Renders form tags and initializes form context.
2726
*/
2827
class FormNode extends StatementNode
@@ -48,6 +47,9 @@ public static function create(Tag $tag): \Generator
4847
$tag->parser->stream->tryConsume(',');
4948
$node->attributes = $tag->parser->parseArguments();
5049
$node->print = $tag->name === 'form';
50+
if (!$node->print) {
51+
trigger_error('Tag {formContext} is deprecated', E_USER_DEPRECATED);
52+
}
5153

5254
[$node->content, $endTag] = yield;
5355
$node->endLine = $endTag?->position;

src/Bridges/FormsLatte/Nodes/FormPrintNode.php

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

2929
public static function create(Tag $tag): static
3030
{
31+
if ($tag->name === 'formPrint') {
32+
trigger_error('Tag {formPrint} is deprecated, use Nette\Forms\Blueprint::latte($form)', E_USER_DEPRECATED);
33+
} else {
34+
trigger_error('Tag {formClassPrint} is deprecated, use Nette\Forms\Blueprint::dataClass($form)', E_USER_DEPRECATED);
35+
}
3136
$node = new static;
3237
$node->name = $tag->parser->isEnd()
3338
? 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
@@ -241,21 +241,4 @@
241241
';
242242
echo $this->global->forms->renderFormEnd() /* pos %d%:1 */;
243243
$this->global->forms->end();
244-
245-
echo '
246-
247-
248-
';
249-
$this->global->forms->begin($form = $this->global->uiControl['myForm']) /* pos %d%:1 */;
250-
echo '
251-
<label';
252-
echo ($ʟ_elem = $this->global->forms->item('sex')->getLabelPart())->attributes() /* pos %d%:8 */;
253-
echo '>';
254-
echo $ʟ_elem->getHtml() /* pos %d%:8 */;
255-
echo '</label>
256-
<input';
257-
echo ($ʟ_elem = $this->global->forms->item('username')->getControlPart())->attributes() /* pos %d%:8 */;
258-
echo '>
259-
';
260-
$this->global->forms->end();
261244
%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)