Skip to content

Commit

Permalink
Latte: {formContext}, {formPrint} & {formClassPrint) are deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 18, 2024
1 parent 97d369d commit e9fc557
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 31 deletions.
4 changes: 3 additions & 1 deletion src/Bridges/FormsLatte/Nodes/FormNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

/**
* {form name} ... {/form}
* {formContext ...}
*/
class FormNode extends StatementNode
{
Expand All @@ -47,6 +46,9 @@ public static function create(Tag $tag): \Generator
$tag->parser->stream->tryConsume(',');
$node->attributes = $tag->parser->parseArguments();
$node->print = $tag->name === 'form';
if (!$node->print) {
trigger_error('Tag {formContext} is deprecated', E_USER_DEPRECATED);
}

[$node->content, $endTag] = yield;
$node->endLine = $endTag?->position;
Expand Down
5 changes: 5 additions & 0 deletions src/Bridges/FormsLatte/Nodes/FormPrintNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class FormPrintNode extends StatementNode

public static function create(Tag $tag): static
{
if ($tag->name === 'formPrint') {
trigger_error('Tag {formPrint} is deprecated, use Nette\Forms\Blueprint::latte($form)', E_USER_DEPRECATED);
} else {
trigger_error('Tag {formClassPrint} is deprecated, use Nette\Forms\Blueprint::dataClass($form)', E_USER_DEPRECATED);
}
$node = new static;
$node->name = $tag->parser->isEnd()
? null
Expand Down
6 changes: 0 additions & 6 deletions tests/Forms.Latte3/expected/forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,3 @@

<select name="select" id="frm-select"><option value="m">male</option><option value="f">female</option></select>
</form>




<label>Sex:</label>
<input type="text" name="username" class="control-class" id="frm-username">
18 changes: 0 additions & 18 deletions tests/Forms.Latte3/expected/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,22 +257,4 @@
';
echo $this->global->forms->renderFormEnd() /* line %d% */;
$this->global->forms->end();

echo '
';
$this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */;
echo '
<label';
echo ($ʟ_elem = $this->global->forms->item('sex')->getLabelPart())->attributes() /* line %d% */;
echo '>';
echo $ʟ_elem->getHtml() /* line %d% */;
echo '</label>
<input';
echo ($ʟ_elem = $this->global->forms->item('username')->getControlPart())->attributes() /* line %d% */;
echo '>
';
/* line %d% */;
$this->global->forms->end();
%A%
6 changes: 0 additions & 6 deletions tests/Forms.Latte3/templates/forms.latte
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,3 @@

<select n:name="select" />
{/form}


{formContext myForm}
<label n:name="sex" />
<input n:name=username>
{/formContext myForm}

0 comments on commit e9fc557

Please sign in to comment.