-
-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Description
We are using control constants to define control names for better orientation in the project code. Unfortunately currently there is no way to do same thing with the snippet. For example:
namespace Vendor\App;
class ExampleForm extends Nette\Application\UI\Form
{
const CONTROL_SUBMIT = 'submit';
const SNIPPET_FORM = 'form';
public function __construct()
{
$this->addSubmit(self::CONTROL_SUBMIT, 'submit')
->onClick[] = array($this, 'handleSubmit');
}
public function handleSubmit(SubmitButton $button)
{
$this->onSubmit($button);
$this->redrawControl(self::SNIPPET_FORM);
}
}{form $control::CONTROL_FORM}
<div n:snippet="$form::SNIPPET_FORM">
{input $form::CONTROL_SUBMIT}
</div>
{/form}or
{form \Vendor\App\ExampleControl::CONTROL_FORM}
<div n:snippet="\Vendor\App\ExampleForm::SNIPPET_FORM">
{input \Vendor\App\ExampleForm::CONTROL_SUBMIT}
</div>
{/form}This example unfortunately will throw the following exception:
Dynamic snippets are allowed only inside static snippet/snippetArea.
zeleznypa
Metadata
Metadata
Assignees
Labels
No labels