nette / examples

🎓 Examples demonstrating the Nette Framework.
https://nette.org
88 stars 52 forks source link

Fixed custom-control example #9

Closed fprochazka closed 10 years ago

fprochazka commented 10 years ago

getControl() must return HTML object so it can be rendered without {$control|noescape}

viz http://nezmar.jabbim.cz/logs/nette@conf.netlab.cz/2014/01/09.html#21:18:22.189294

dg commented 10 years ago

Is there any example where is form rendered via {$control} ?

fprochazka commented 10 years ago

My point is that it is not a standard way to write controls. Every other control returns Html object and so should this one.

$template = new \Nette\Templating\Template();
$source = <<<LATTE
<form n:name="\$form">
    <input n:name="date">
</form>
LATTE;

$template->setSource($source);
$template->setCacheStorage(new \Nette\Caching\Storages\DevNullStorage());
$template->registerFilter(new \Nette\Latte\Engine());
$template->registerHelperLoader('Nette\Templating\Helpers::loader');

$template->form = $form;

echo $template;
Fatal Error

Call to a member function attributes() on a non-object
dg commented 10 years ago

But with your fix it will generate empty <input>.

fprochazka commented 10 years ago

Heh, good point. I don't know then. But I still think it's better when it returns Html object rather than string.

fprochazka commented 10 years ago

:disappointed:

dg commented 10 years ago

It is here https://github.com/nette/examples/commit/791b2a19c1bb675f697833e472d6ee85be4474be but I don't like it...

fprochazka commented 10 years ago

Consistency is always good!