Hi Thomas,

thanks for your further comments. That helped me a lot to understand the
validation part more.

Anyway, with the help of Kai Uwe I found another solution for my
problem. I wrote a form decorator which adds the validation to the form
automatically. It just adds a function with the addOnLoad() method of
the dojo view helper. Here is a snippet from this decorator.

  // add validate method to form
  $element = $this->getElement();
  $view    = $element->getView();

  $view->dojo()->addOnLoad('function() {
    dojo.connect(dijit.byId("' . $element->getName() . '"),
    "onSubmit",
    function () {
      var form = dijit.byId("' . $element->getName() . '");
      if (!form.validate()) {
        return false;
      }
      return true;
    });
  }');

It works like a charme since it marks all false elements and sets the
focus to the first false element.

Thanks and best regards,

Ralf

Reply via email to