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 Dec 11, 2023
1 parent 584bbf0 commit e14e0b9
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" data-nette-error>
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 '
';
$form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */;
Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
echo '
<label';
echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item('sex', $this->global)->getLabelPart())->attributes() /* line %d% */;
echo '>';
echo $ʟ_elem->getHtml() /* line %d% */;
echo '</label>
<input';
echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item('username', $this->global)->getControlPart())->attributes() /* line %d% */;
echo '>
';
array_pop($this->global->formsStack) /* line %d% */;
%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 e14e0b9

Please sign in to comment.