Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onValidate callback in Forms\Container not called when submitting Form #27

Closed
janedbal opened this issue Jul 11, 2014 · 0 comments
Closed

Comments

@janedbal
Copy link

Really confusing about creating form containers is that you cannot use onValidate property for adding validation callbacks. It is never used. See following example.

class HomepagePresenter extends BasePresenter {

  protected function createComponentTestForm(){
    $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;
  }

  public function formValidation(){
        echo "validation from form ok"; // works
  }

   public function containerValidation(){
        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

@dg dg closed this as completed in 347c545 Aug 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant