nette / forms

📝 Generating, validating and processing secure forms in PHP. Handy API, fully customizable, server & client side validation and mature design.

Home Page:https://doc.nette.org/forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

macro formPrint throws exception if getControlPart is called

MartkCz opened this issue · comments

Version: 3.0.6

I've following checkbox:

$form->addCheckbox('checkbox');

and simple template:

<div class="col-sm-10 col-sm-offset-2">
		<div class="checkbox">
			<label for="{$val->getHtmlId()}">
				{$val->getControlPart()} {$val->caption}
			</label>
		</div>

		{include controlErrors $val}
	</div>

throws exception: Return value of Nette\Forms\Controls\BaseControl::getControlPart() must be an instance of Nette\Utils\Html or null, string returned

because of https://github.com/nette/forms/blob/master/src/Bridges/FormsLatte/Runtime.php#L97

possible solution:

return \Nette\Utils\Html::fromText('{input ' . $this->inner->lookupPath(Form::class) . '}');

I don't get it at all. How are formPrint and the template related?