You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Really confusing about creating form containers is that you cannot use onValidate property for adding validation callbacks. It is never used. See following example.
classHomepagePresenterextendsBasePresenter {
protectedfunctioncreateComponentTestForm(){
$form = new \Nette\Application\UI\Form;
$form->addContainer("container"); // just exmaple, could be separate class$form["container"]->addText("foo", "Bar");
$form["container"]->onValidate[] = array($this, "containerValidation");
$form->addSubmit("send");
$form->onValidate[] = array($this, "formValidation");
return$form;
}
publicfunctionformValidation(){
echo "validation from form ok"; // works
}
publicfunctioncontainerValidation(){
echo "validation from container ok"; // doesn't work
}
}
I understand that this callback is used by Form which extends Forms\Container, but if it cannot be used in "standalone" form container, shouldn't this property be in Form? Also the phpdoc makes the confusion even bigger. It says: "Occurs when the form is validated".
EDIT: removed workaround
The text was updated successfully, but these errors were encountered:
Really confusing about creating form containers is that you cannot use
onValidate
property for adding validation callbacks. It is never used. See following example.I understand that this callback is used by Form which extends Forms\Container, but if it cannot be used in "standalone" form container, shouldn't this property be in Form? Also the phpdoc makes the confusion even bigger. It says: "Occurs when the form is validated".
EDIT: removed workaround
The text was updated successfully, but these errors were encountered: