/**
  * Execute the actions of the form builder validated.
  *
  * @access private
  * @return void
  *
  * @author Etienne de Longeaux <*****@*****.**>
  * @since 2012-09-11
  */
 private function dispatchAction()
 {
     // we get the values of the form builder validated.
     if ($this->getTypeForm() == "zend") {
         $this->_data = null;
     } elseif ($this->getTypeForm() == "symfony") {
         $this->_data = $this->_form->getData();
     }
     // we only Execute the actions of the form builder validated.
     if ($this->getName() == $this->_id_form) {
         // we Execute the pre event action of the form builder validated.
         $this->preEventActionForm($this->_data);
         // we create the xml config value if it is defined in the form builder validated.
         try {
             $XmlConfigWidget = $this->XmlConfigWidget($this->_data);
             if (is_array($XmlConfigWidget) && count($XmlConfigWidget) >= 1) {
                 \Sfynx\ToolBundle\Util\PiArrayManager::init('1.0', 'UTF-8');
                 $this->_xmlconfig = \Sfynx\ToolBundle\Util\PiArrayManager::createXML('config', $XmlConfigWidget['xml'])->saveXML();
             } else {
                 $this->_xmlconfig = null;
             }
         } catch (\Exception $e) {
             $this->_xmlconfig = null;
         }
         // we create/update a widget if the xml config value is defined.
         try {
             if (!is_null($this->_xmlconfig) && $this->_performName == "insert") {
                 $this->insertWidget($XmlConfigWidget['plugin'], $XmlConfigWidget['action']);
             } elseif (!is_null($this->_xmlconfig) && $this->_performName == "update") {
                 $this->updateWidget($XmlConfigWidget['plugin'], $XmlConfigWidget['action']);
             }
         } catch (\Exception $e) {
         }
         // we throw the post event action of the form builder validated.
         $this->postEventActionForm($this->_data);
     }
 }
Пример #2
0
 /**
  * Get all error messages after binding form.
  *
  * @param Form   $form
  * @param string $type
  * @param string $delimiter
  * 	
  * @return array The list of all the errors
  * @access protected
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function getFormErrors(Form $form, $type = 'array', $delimiter = "<br />")
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         if ($error->getMessagePluralization() !== null) {
             $errors[$key] = array('id' => $error->getMessage(), 'trans' => $this->get('translator')->transChoice($error->getMessage(), $error->getMessagePluralization(), $error->getMessageParameters()));
         } else {
             $errors[$key] = array('id' => $error->getMessage(), 'trans' => $this->get('translator')->trans($error->getMessage()));
         }
     }
     $all = $form->all();
     if (is_array($all)) {
         foreach ($all as $child) {
             if (!$child->isValid()) {
                 $errors[$child->getName()] = $this->getFormErrors($child, 'array');
             }
         }
     }
     if ($type == 'array') {
         return $errors;
     } else {
         return PiArrayManager::convertArrayToString($errors, $this->get('translator'), 'pi.form.label.field.', '', $delimiter);
     }
 }