-
-
Notifications
You must be signed in to change notification settings - Fork 151
Closed
Description
Hello!
I need to create a form with a field read-only and later make it active, but get the error after submit - Undefined property: Nette\Utils\ArrayHash::$test2. Below I have given examples of code that I use. Form becomes active and you can select any item after $this->redrawControl('forms').
Example form:
public function create()
{
$form = new Form();
$form->addSelect('test', '', [
'1' => 'lalala'
])
->setRequired('Just do it!');
$form->addSelect('test2', '', [
'1' => '123123'
])
->setDisabled(true)
->setRequired('Just do it!');
$form->addProtection('');
$form->addSubmit('send', 'create');
$form->onSuccess[] = function (Form $form, $values) {
$form->addError($values->test2);
};
return $form;
}
I have a script that tracks changes test
public function handleChange($change)
{
if ($change) {
$this['orderForm']['test2']->setDisabled(false);
} else {
$this['orderForm']['test2']->setDisabled(true);
}
$this->redrawControl('wrapper');
$this->redrawControl('forms');
}
Metadata
Metadata
Assignees
Labels
No labels