Skip to content

Commit 9116754

Browse files
committed
Latte: {formContext}, {formPrint} & {formClassPrint) are deprecated
1 parent c0c533a commit 9116754

File tree

5 files changed

+8
-30
lines changed

5 files changed

+8
-30
lines changed

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} ... {/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

Lines changed: 5 additions & 0 deletions
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.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)