コード例 #1
0
 /**
  * @return Form
  */
 public final function create()
 {
     $form = new Form();
     $form->setTranslator($this->translator);
     $form->setRenderer($this->getFormRenderer());
     $this->build($form);
     $form->onAttached[] = function (Form $self) {
         $this->buildToggles($self, "frm-{$self->name}");
     };
     $form->beforeValidate[] = function (Form $self) {
         return $this->beforeValidate($self->values);
     };
     $form->onValidate[] = function (Form $self) {
         $this->onValidate($self);
     };
     return $form;
 }
コード例 #2
0
 /**
  * @param IFormEntity|null $entity
  * @return Form
  */
 public final function create(IFormEntity $entity = NULL)
 {
     $form = new Form();
     $form->setTranslator($this->translator);
     $form->setRenderer($this->getFormRenderer());
     $this->build($form, $entity);
     $form->onAttached[] = function (Form $self) use($entity) {
         $this->buildToggles($self, "frm-{$self->name}");
         if ($entity !== NULL) {
             $this->setDefaultsByEntity($self, $entity);
         }
     };
     $form->beforeValidate[] = function (Form $self) {
         return $this->beforeValidate($self->values);
     };
     $form->onValidate[] = function (Form $self) use($entity) {
         $this->onValidate($self, $entity);
     };
     return $form;
 }