Skip to content

Commit e938d9a

Browse files
committed
Latte: {formContext}, {formContainer}, {formPrint} & {formClassPrint) are deprecated
1 parent 75fd44f commit e938d9a

6 files changed

Lines changed: 9 additions & 30 deletions

File tree

src/Bridges/FormsLatte/Nodes/FormContainerNode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class FormContainerNode extends StatementNode
2727
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
2828
public static function create(Tag $tag): \Generator
2929
{
30+
trigger_error('Tag {formContainer} is deprecated, use {form scope}', E_USER_DEPRECATED);
3031
$tag->outputMode = $tag::OutputRemoveIndentation;
3132
$tag->expectArguments();
3233

src/Bridges/FormsLatte/Nodes/FormNode.php

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

2121
/**
2222
* {form [scope|detached] name [, attributes]} ... {/form}
23-
* {formContext name} ... {/formContext}
2423
* Renders form tags and initializes form context.
2524
*/
2625
class FormNode extends StatementNode
@@ -45,6 +44,9 @@ public static function create(Tag $tag): \Generator
4544
$tag->outputMode = $tag::OutputKeepIndentation;
4645
$tag->expectArguments();
4746
$node = $tag->node = new static;
47+
if ($tag->name === 'formContext') {
48+
trigger_error('Tag {formContext} is deprecated, use {form scope}', E_USER_DEPRECATED);
49+
}
4850
$node->mode = match (true) {
4951
$tag->name === 'formContext' => self::ModeLegacyScope,
5052
in_array($tag->parser->stream->tryPeek()?->text, [self::ModeScope, self::ModeDetached], strict: true) => $tag->parser->stream->consume()->text,

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)