Example #1
0
 protected function attachHandlers($form)
 {
     if (method_exists($this, 'handleCatchError')) {
         $this->onCatchError[] = callback($this, 'handleCatchError');
     }
     return parent::attachHandlers($form);
 }
Example #2
0
 /**
  * @return \Venne\Forms\IFormFactory
  */
 public function create()
 {
     $form = parent::create();
     $form['_eventControl'] = $eventControl = new EventControl('_eventControl');
     $eventControl->onAttached[] = function () use($form) {
         $this->entityMapper->load($this->entity, $form);
         unset($form['_eventControl']);
     };
     $form->onSuccess[] = function (Form $form) {
         $this->entityMapper->save($this->entity, $form);
         $saveEntity = $this->saveEntity;
         if ($saveEntity && $saveEntity($form)) {
             try {
                 $this->entityMapper->getEntityManager()->flush($this->entity);
             } catch (\Exception $e) {
                 Debugger::log($e);
                 $form->addError($e->getMessage());
             }
         }
     };
     return $form;
 }
 protected function getControlExtensions()
 {
     return array_merge(parent::getControlExtensions(), array(new ControlExtension()));
 }
Example #4
0
 /**
  * @return \Venne\Forms\Form
  */
 protected function createComponentForm()
 {
     $form = $this->setupFormFactory->invoke($this->getExtendedElement());
     $form->onSuccess[] = $this->processForm;
     return $form;
 }