Example #1
0
 /**
  * Main method used to generate HTML Form based on the backend input
  *
  * @param FormEntity $form
  * @throws \Symfony\Component\Security\Acl\Exception\Exception
  * @return String HTML of the generated form.
  */
 public function buildHtmlForm(FormEntity $form)
 {
     $html = $form->getSource();
     $tags = $this->parseTags($html);
     foreach ($tags as $id => $tag) {
         $matches = null;
         $htmlTag = $this->renderTag($id, $tag);
         $pattern = "#<field .*id=\"" . $id . "\".*/>#";
         preg_match($pattern, $html, $matches);
         if (!$matches) {
             throw new Exception("Unable to replace TAG ID : " . $id);
         }
         $html = str_replace($matches[0], $htmlTag, $html);
     }
     $html = $this->setFormTag($html);
     $html = $this->setHiddenTags($form, $html);
     $html = $this->setJsTag($form, $html);
     list($isValid, $error_msg) = $this->checkFormValidity($html);
     if ($isValid) {
         return $html;
     } else {
         return "form has errors";
     }
 }