private function generateFieldHtml($form, $field, $arr_options = array()) { //make sure field does exist in form, form might have been manipulated since it has been received from the Core if (!$form->has($field)) { return; } //end if //extract element title for help sections $title = $form->get($field)->getAttribute("title"); //set label classes $form->get($field)->setLabelAttributes(array("class" => "control-label")); //set tooltip if ($title != "") { $form->get($field)->setAttribute("data-toggle", "tooltip"); } //end if //open form element if (strtolower($form->get($field)->getAttribute("type") == "hidden")) { //do nothing $html .= "<div style=\"display: none;\">"; } else { $html .= "<div>"; } //end if //set parent element classes //check for required elements if ($form->get($field)->getAttribute("required") == "required") { $parent_css_classes = "has-feedback"; } //end if //check for element errors if (count($form->get($field)->getMessages()) > 0) { $parent_css_classes = "has-feedback has-error"; } //end if //check for checkbox and radios if ($form->get($field)->getAttribute("type") == "checkbox") { $parent_css_classes .= "checkbox-inline"; } //end if $html .= "<div class=\"form-group form-element-" . $field . " {$parent_css_classes}\">"; switch (strtolower($form->get($field)->getAttribute("type"))) { default: if (strtolower($form->get($field)->getAttribute("name")) == "submit") { //do nothing $html .= "</div>"; } else { if ($form->get($field)->getLabel() != "") { $html .= $this->view->formLabel($form->get($field)); } //end if $form->get($field)->setAttribute("class", "form-control"); $html .= $this->view->formElement($form->get($field)); if ($form->get($field)->getAttribute("required") == "required") { $html .= "<span class=\"glyphicon glyphicon-asterisk form-control-feedback\"></span>"; } //end if //add help text if ($title != "") { if (is_array($arr_options) && (!isset($arr_options["disable_help_button"]) || $arr_options["disable_help_button"] !== TRUE)) { $html .= "<span class=\"help-block\">{$title}</span>"; } //end if } //end if //add errors $html .= $this->view->formElementerrors($form->get($field)); $html .= "</div>"; } //end if break; $form->get($field)->setLabelAttributes(array("class" => "control-label", "class" => "selector-width")); case "checkbox": case "radio": $form->get($field)->setAttribute("class", "selector-width"); $html .= $this->view->formElement($form->get($field)); if ($form->get($field)->getLabel() != "") { $html .= $this->view->formLabel($form->get($field)); } //end if if ($form->get($field)->getAttribute("required") == "required") { $html .= "<span class=\"glyphicon glyphicon-asterisk form-control-feedback\"></span>"; } //end if //add help text if ($title != "") { if (is_array($arr_options) && (!isset($arr_options["disable_help_button"]) || $arr_options["disable_help_button"] !== TRUE)) { $html .= "<span class=\"help-block\">{$title}</span>"; } //end if } //end if //add errors $html .= $this->view->formElementerrors($form->get($field)); $html .= "</div>"; break; case "textarea": if ($form->get($field)->getLabel() != "") { $html .= $this->view->formLabel($form->get($field)); } //end if $form->get($field)->setAttribute("class", "form-control"); $html .= $this->view->formElement($form->get($field)); if ($form->get($field)->getAttribute("required") == "required") { $html .= "<span class=\"glyphicon glyphicon-asterisk form-control-feedback\"></span>"; } //end if //add help text if ($title != "") { if (is_array($arr_options) && (!isset($arr_options["disable_help_button"]) || $arr_options["disable_help_button"] !== TRUE)) { $html .= "<span class=\"help-block\">{$title}</span>"; } //end if } //end if //add errors $html .= $this->view->formElementerrors($form->get($field)); $html .= "</div>"; $arr_attributes = $form->get($field)->getAttributes(); if (strpos($arr_attributes["class"], "text-editor") !== FALSE) { $html .= "<script type=\"text/javascript\">\n\t\t\t\t\t\t\t\t\t\tjQuery(document).ready(function () {\n\t\t\t\t\t\t\t\t\t\t\tjQuery(\"#" . $arr_attributes["id"] . "\").attr(\"required\", false);\n\t\t\t\t\t\t\t\t\t\t\ttinyMCE.init({\n\t\t\t\t\t\t\t\t\t\t\t\tselector: \"#" . $arr_attributes["id"] . "\",\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t</script>"; } //end if break; case "hidden": $html .= $this->view->formElement($form->get($field)); $html .= "</div>"; break; } //end switch //close form element $html .= "</div>"; return $html; }
private function generateFieldHtml($form, $field) { //check if field names should be displayed if ($_GET["show_field_names"] == 1) { $form->get($field)->setLabel($form->get($field)->getLabel() . " - (<span style=\"font-weight: bold;\">" . $form->get($field)->getName() . "</span>)"); } //end if $form->get($field)->setLabelAttributes(array("class" => "label")); switch (strtolower($form->get($field)->getAttribute("type"))) { default: if (strtolower($form->get($field)->getAttribute("name")) == "submit") { //do nothing } else { $html .= "<div class=\"form-element form-element-" . $field . " \">"; $html .= "<div class='container container_field'>"; $html .= $this->view->formLabel($form->get($field)); $html .= "</div>"; $html .= $this->view->formElement($form->get($field)); //add required information if ($form->get($field)->getAttribute("required") == "required") { $html .= "<span class=\"required-input\">*</span>"; } //end if //add element errors where set if (count($form->get($field)->getMessages()) > 0) { $html .= $this->view->formElementErrors($form->get($field)); } //end if $html .= "</div>"; } //end if break; // case "textarea": // $html .= "<div class=\"form-element form-element-" . $field . " \">"; // $html .= "<div class='container container_field'>"; // $html .= $this->view->formLabel($form->get($field)); // $html .= "</div>"; // $html .= $this->view->formElement($form->get($field)); // //add required information // if ($form->get($field)->getAttribute("required") == "required") // { // $html .= "<span class=\"required-input\">*</span>"; // }//end if // //add element errors where set // if (count($form->get($field)->getMessages()) > 0) // { // $html .= $this->view->formElementErrors($form->get($field)); // }//end if // $arr_attributes = $form->get($field)->getAttributes(); // if (strpos($arr_attributes["class"], "text-editor") !== FALSE) // { // $html .= "<script type=\"text/javascript\"> // jQuery(document).ready(function () { // jQuery(\"#". $arr_attributes["id"] . "\").attr(\"required\", false); // tinyMCE.init({ // selector: \"#" . $arr_attributes["id"] . "\" // }); // }); // </script>"; // }//end if // $html .= "</div>"; // break; // case "textarea": // $html .= "<div class=\"form-element form-element-" . $field . " \">"; // $html .= "<div class='container container_field'>"; // $html .= $this->view->formLabel($form->get($field)); // $html .= "</div>"; // $html .= $this->view->formElement($form->get($field)); // //add required information // if ($form->get($field)->getAttribute("required") == "required") // { // $html .= "<span class=\"required-input\">*</span>"; // }//end if // //add element errors where set // if (count($form->get($field)->getMessages()) > 0) // { // $html .= $this->view->formElementErrors($form->get($field)); // }//end if // $arr_attributes = $form->get($field)->getAttributes(); // if (strpos($arr_attributes["class"], "text-editor") !== FALSE) // { // $html .= "<script type=\"text/javascript\"> // jQuery(document).ready(function () { // jQuery(\"#". $arr_attributes["id"] . "\").attr(\"required\", false); // tinyMCE.init({ // selector: \"#" . $arr_attributes["id"] . "\" // }); // }); // </script>"; // }//end if // $html .= "</div>"; // break; case "date": $html .= "<div class=\"form-element form-element-" . $field . " \">"; $html .= "<div class='container container_field'>"; $html .= $this->view->formLabel($form->get($field)); $html .= "</div>"; $html .= $this->view->formElement($form->get($field)); //add required information if ($form->get($field)->getAttribute("required") == "required") { $html .= "<span class=\"required-input\">*</span>"; } //end if //add element errors where set if (count($form->get($field)->getMessages()) > 0) { $html .= $this->view->formElementErrors($form->get($field)); } //end if $arr_attributes = $form->get($field)->getAttributes(); if (strpos($arr_attributes["class"], "date-picker") !== FALSE) { $html .= "<script type=\"text/javascript\">\n\t\t\t\t\t\t\t\t\tjQuery(document).ready(function () {\n\t\t\t\t\t\t\t\t\t\tjQuery(\"#" . $field . "\").datepicker({ dateFormat: \"dd-mm-yy\" });\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t</script>"; } //end if $html .= "</div>"; break; case "hidden": $html .= $this->view->formElement($form->get($field)); break; } //end switch //Added code to set calss on submit button $form->get("submit")->setAttribute("class", "submit"); return $html; }