Skip to content

Commit e9fc557

Browse files
committed
Latte: {formContext}, {formPrint} & {formClassPrint) are deprecated
1 parent 97d369d commit e9fc557

File tree

5 files changed

+8
-31
lines changed

5 files changed

+8
-31
lines changed

src/Bridges/FormsLatte/Nodes/FormNode.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
/**
2424
* {form name} ... {/form}
25-
* {formContext ...}
2625
*/
2726
class FormNode extends StatementNode
2827
{
@@ -47,6 +46,9 @@ public static function create(Tag $tag): \Generator
4746
$tag->parser->stream->tryConsume(',');
4847
$node->attributes = $tag->parser->parseArguments();
4948
$node->print = $tag->name === 'form';
49+
if (!$node->print) {
50+
trigger_error('Tag {formContext} is deprecated', E_USER_DEPRECATED);
51+
}
5052

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

src/Bridges/FormsLatte/Nodes/FormPrintNode.php

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class FormPrintNode extends StatementNode
2727

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

tests/Forms.Latte3/expected/forms.html

-6
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,3 @@
111111

112112
<select name="select" id="frm-select"><option value="m">male</option><option value="f">female</option></select>
113113
</form>
114-
115-
116-
117-
118-
<label>Sex:</label>
119-
<input type="text" name="username" class="control-class" id="frm-username">

tests/Forms.Latte3/expected/forms.php

-18
Original file line numberDiff line numberDiff line change
@@ -257,22 +257,4 @@
257257
';
258258
echo $this->global->forms->renderFormEnd() /* line %d% */;
259259
$this->global->forms->end();
260-
261-
echo '
262-
263-
264-
';
265-
$this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */;
266-
echo '
267-
<label';
268-
echo ($ʟ_elem = $this->global->forms->item('sex')->getLabelPart())->attributes() /* line %d% */;
269-
echo '>';
270-
echo $ʟ_elem->getHtml() /* line %d% */;
271-
echo '</label>
272-
<input';
273-
echo ($ʟ_elem = $this->global->forms->item('username')->getControlPart())->attributes() /* line %d% */;
274-
echo '>
275-
';
276-
/* line %d% */;
277-
$this->global->forms->end();
278260
%A%

tests/Forms.Latte3/templates/forms.latte

-6
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,3 @@
8080

8181
<select n:name="select" />
8282
{/form}
83-
84-
85-
{formContext myForm}
86-
<label n:name="sex" />
87-
<input n:name=username>
88-
{/formContext myForm}

0 commit comments

Comments
 (0)