/**
  * Generate a form with field Groups
  * @param objForm $form
  * @param \Zend\Mvc\View\View $view
  * @param array $arr_options - Optional
  * @return mixed
  */
 private function generateFormWithFieldGroups($form, $view, $arr_options = array())
 {
     //extract field groups
     $arr_field_groups = (array) $form->getAttribute("arr_field_groups");
     $form->remove("arr_field_groups");
     if (!is_array($arr_field_groups)) {
         return FALSE;
     }
     //end if
     //set unique id
     $java_id = str_replace(".", "", microtime(TRUE));
     //open html string
     $html = "";
     //check if accordion must be enabled
     if ($arr_options["enable_accordion"] === TRUE) {
         //add javascript to load accodian plugin
         $html .= "<script type=\"text/javascript\">";
         $html .= "jQuery(document).ready(function () {\n\t\t\t\t\t\t\tjQuery(\".{$java_id}\").mj_accordion();\n\t\t\t\t\t\t });";
         $html .= "</script>";
     }
     //end if
     //open the form tag
     $html .= "<div>";
     if ($arr_options["disable_help_button"] !== TRUE) {
         //add help toggle button
         $html .= "<span id=\"frm-toggle-help\" class=\"btn btn-warning\" title=\"Toggle Help\" data-toggle=\"tooltip\"><span class=\"glyphicon glyphicon-question-sign\"></span></span>";
     }
     //end if
     $html .= $view->form()->openTag($form);
     //add accordion div element
     $html .= "<div class=\"{$java_id} style-js-accordion\">";
     //custom form element error structure
     $view->formElementErrors()->setMessageOpenFormat('<div class="bg-danger help-inline" style="padding: 10px; margin-top: 5px; margin-bottom: 5px;">')->setMessageSeparatorString('</div><div>')->setMessageCloseString('</div>');
     foreach ($arr_field_groups as $key => $arr_fields) {
         //make sure that this groups does contain fields
         if (count($arr_fields) == 0) {
             continue;
         }
         //end if
         $html .= "<div class=\"panel panel-default m3-panel-subsection\">";
         $html .= "<h3 class=\"panel-title panel-heading \"><span class=\"m3-panel-subsection-icon glyphicon glyphicon-resize-full\"></span>&nbsp;{$key}</h3>";
         $html .= "</div>";
         $html .= "<div class=\"accordion-section\">";
         foreach ($arr_fields as $section_internal_group => $field) {
             //check for grouped fields within section
             if (is_array($field)) {
                 //create fieldset
                 $html .= "<fieldset><legend>{$section_internal_group}</legend>";
                 foreach ($field as $group => $grouped_field) {
                     $html .= $this->generateFieldHtml($form, $grouped_field, $arr_options);
                 }
                 //end foreach
                 //close fieldset
                 $html .= "</fieldset>";
             } else {
                 $html .= $this->generateFieldHtml($form, $field, $arr_options);
             }
             //end if
         }
         //end foreach
         $html .= "</div>";
     }
     //end foreach
     //collapse field group array
     foreach ($arr_field_groups as $key => $arr_fields) {
         foreach ($arr_fields as $field) {
             if (is_array($field)) {
                 foreach ($field as $grouped_field) {
                     $arr_collapsed_field_groups[] = $grouped_field;
                 }
                 //end foreach
             } else {
                 $arr_collapsed_field_groups[] = $field;
             }
             //end if
         }
         //end foreach
     }
     //end foreach
     //make sure that all elements have been rendered
     $objElements = $form->getElements();
     foreach ($objElements as $field => $objElement) {
         if (!in_array($field, $arr_collapsed_field_groups)) {
             $html .= $this->generateFieldHtml($form, $field);
             continue;
         }
         //end if
     }
     //end foreach
     //close accordion div
     $html .= "</div><br/>";
     if ($form->has("submit")) {
         $form->get("submit")->setAttribute("class", "btn btn-primary");
         $form->get("submit")->setValue("Save");
         $html .= $view->formSubmit($form->get("submit"));
     }
     //end if
     //close the form
     $html .= $view->form()->closeTag();
     $html .= "</div>";
     //append js utils
     if (!isset($arr_options["appendJavaScriptUtils"]) || isset($arr_options["appendJavaScriptUtils"]) && $arr_options["appendJavaScriptUtils"] !== FALSE) {
         $html .= $this->appendJavaScriptUtils($arr_options);
     }
     //end if
     return $html;
 }
 /**
  * Generate a form with field Groups
  * @param objForm $form
  * @param \Zend\Mvc\View\View $view
  * @param array $arr_options - Optional
  * @return mixed
  */
 private function generateFormWithFieldGroups($form, $view, $arr_options = NULL)
 {
     //extract field groups
     $arr_field_groups = (array) $form->getAttribute("arr_field_groups");
     $form->remove("arr_field_groups");
     if (!is_array($arr_field_groups)) {
         return FALSE;
     }
     //end if
     //set unique id
     $java_id = str_replace(".", "", microtime(TRUE));
     //open html string
     $html = "";
     //check if accordion must be enabled
     if ($arr_options["enable_accordion"] === TRUE) {
         //add javascript to load accodian plugin
         $html .= "<script type=\"text/javascript\">";
         $html .= "jQuery(document).ready(function () {\n\t\t\t\t\t\t\tjQuery(\".{$java_id}\").mj_accordion();\n\t\t\t\t\t\t });";
         $html .= "</script>";
     }
     //end if
     //set form class attribute
     $form->setAttribute("class", "form");
     //open the form tag
     $html .= $view->form()->openTag($form);
     //add accordion div element
     $html .= "<div class=\"{$java_id} style-js-accordion\">";
     //custom form element error structure
     $view->formElementErrors()->setMessageOpenFormat('<div class="bg-danger help-inline" style="padding: 10px; margin-top: 5px; margin-bottom: 5px;">')->setMessageSeparatorString('</div><div>')->setMessageCloseString('</div>');
     foreach ($arr_field_groups as $key => $arr_fields) {
         //make sure that this groups does contain fields
         if (count($arr_fields) == 0) {
             continue;
         }
         //end if
         $html .= "<h3>{$key}</h3>";
         $html .= "<div class=\"accordion-section\">";
         foreach ($arr_fields as $section_internal_group => $field) {
             //check for grouped fields within section
             if (is_array($field)) {
                 //create fieldset
                 $html .= "<fieldset><legend>{$section_internal_group}</legend>";
                 foreach ($field as $group => $grouped_field) {
                     $html .= $this->generateFieldHtml($form, $grouped_field);
                 }
                 //end foreach
                 //close fieldset
                 $html .= "</fieldset>";
             } else {
                 $html .= $this->generateFieldHtml($form, $field);
             }
             //end if
         }
         //end foreach
         //$html .= "</div>"; Commented out by Lodi
     }
     //end foreach
     //collapse field group array
     foreach ($arr_field_groups as $key => $arr_fields) {
         foreach ($arr_fields as $field) {
             if (is_array($field)) {
                 foreach ($field as $grouped_field) {
                     $arr_collapsed_field_groups[] = $grouped_field;
                 }
                 //end foreach
             } else {
                 $arr_collapsed_field_groups[] = $field;
             }
             //end if
         }
         //end foreach
     }
     //end foreach
     //make sure that all elements have been rendered
     $objElements = $form->getElements();
     foreach ($objElements as $field => $objElement) {
         if (!in_array($field, $arr_collapsed_field_groups)) {
             $html .= $this->generateFieldHtml($form, $field);
             continue;
         }
         //end if
     }
     //end foreach
     //close accordion div
     $html .= "</div><br/>";
     if ($form->has("submit")) {
         if ($form->get("submit")->getValue() == "") {
             $form->get("submit")->setAttribute("class", "submit");
             $form->get("submit")->setValue("Submit");
         }
         //end if
         $html .= $view->formSubmit($form->get("submit"));
     }
     //end if
     //close the form
     $html .= $view->form()->closeTag();
     return $html;
 }