public static function process_form_elements(FormElement $element) { ($element->getLabel() != null and $element->getLabel() != "") ? $isLabel = true : ($isLabel = false); ($element->getId() != null and $element->getId() != "") ? $label = $element->getId() : ($label = $element->getName()); $output = ""; // On case les checkbox / radio dans une div chez nous :) if (isset($element->getAttributes()['type'])) { if (!self::$flag_process_form_elements_radio_list_open) { if (!self::$flag_process_form_elements_checkbox_list_open and $element->getAttributes()['type'] == 'checkbox') { self::$flag_process_form_elements_checkbox_list_open = true; $output .= "<div style=\"float:left;\">"; } else { if (self::$flag_process_form_elements_checkbox_list_open and $element->getAttributes()['type'] != 'checkbox') { self::$flag_process_form_elements_checkbox_list_open = false; $output .= "</div><div style=\"clear:both;\"></div>"; } } } if (!self::$flag_process_form_elements_checkbox_list_open) { if (!self::$flag_process_form_elements_radio_list_open and $element->getAttributes()['type'] == 'radio') { self::$flag_process_form_elements_radio_list_open = true; $output .= "<div style=\"float:left;\">"; } else { if (self::$flag_process_form_elements_radio_list_open and $element->getAttributes()['type'] != 'radio') { self::$flag_process_form_elements_radio_list_open = false; $output .= "</div><div style=\"clear:both;\"></div>"; } } } } else { if (self::$flag_process_form_elements_radio_list_open or self::$flag_process_form_elements_checkbox_list_open) { self::$flag_process_form_elements_checkbox_list_open = false; self::$flag_process_form_elements_radio_list_open = false; $output .= "</div><div style=\"clear:both;\"></div>"; } } // Element auto-fermable if ($element->is_closed()) { if ($isLabel and isset($element->getAttributes()['type']) and ($element->getAttributes()['type'] != 'radio' and $element->getAttributes()['type'] != 'checkbox')) { $output .= "<div class=\"formulaire_ligne\"><label for=\"" . $label . "\">" . $element->getLabel() . "</label>"; } if (isset($element->getAttributes()['type']) and ($element->getAttributes()['type'] == 'checkbox' or $element->getAttributes()['type'] == 'radio')) { $output .= "<div class=\"FormElementCheckboxRadio\">"; } $output .= "<" . $element->getBalise(); if ($element->getId() != null and $element->getId() != "") { $output .= " id=\"" . $element->getId() . "\""; } if ($element->getName() != null and $element->getName() != "") { $output .= " name=\"" . $element->getName() . "\""; } $output .= " value=\"" . $element->getValue() . "\""; foreach ($element->getAttributes() as $k => $v) { $output .= " {$k}=\"{$v}\""; if ($k == 'type' and $v == 'radio') { $output .= " class=\"radio\""; } } $output .= "/>"; if ($isLabel and isset($element->getAttributes()['type']) and $element->getAttributes()['type'] == 'checkbox') { $output .= "<label for=\"" . $label . "\"><span class=\"ui\"></span><span class=\"label\">" . $element->getLabel() . "</span></label>"; $output .= "</div>"; } else { if ($isLabel and isset($element->getAttributes()['type']) and $element->getAttributes()['type'] == 'radio') { $output .= "<label for=\"" . $label . "\"><span class=\"ui\"></span><span class=\"label\">" . $element->getLabel() . "</span></label>"; $output .= "</div>"; } else { if ($isLabel and isset($element->getAttributes()['type']) and ($element->getAttributes()['type'] != 'radio' and $element->getAttributes()['type'] != 'checkbox')) { $output .= "</div>"; } } } } else { if ($isLabel and (strtolower($element->getBalise()) == "select" or strtolower($element->getBalise()) == "textarea")) { $output .= "<label for=\"" . $label . "\">" . $element->getLabel() . "</label>"; } $output .= "<" . $element->getBalise(); if ($element->getId() != null and $element->getId() != "") { $output .= " id=\"" . $element->getId() . "\""; } if ($element->getName() != null and $element->getName() != "") { $output .= " name=\"" . $element->getName() . "\""; } $output .= " value=\"" . $element->getValue() . "\""; foreach ($element->getAttributes() as $k => $v) { $output .= " {$k}=\"{$v}\""; } $output .= ">"; if (sizeof($element->getElements()) > 0) { foreach ($element->getElements() as $v) { $output .= self::process_form_elements($v); } } else { if (strtolower($element->getBalise()) != "textarea") { $output .= $element->getLabel(); } else { $output .= $element->getValue(); } } $output .= "</" . $element->getBalise() . ">"; } return $output; }
public static function process_form_elements(FormElement $element) { ($element->getLabel() != null and $element->getLabel() != "") ? $isLabel = true : ($isLabel = false); ($element->getId() != null and $element->getId() != "") ? $label = $element->getId() : ($label = $element->getName()); $output = ""; // Element auto-fermable if ($element->is_closed()) { if ($isLabel and ($element->getAttributes()['type'] != 'radio' and $element->getAttributes()['type'] != 'checkbox')) { $output .= "<label for=\"" . $label . "\">" . $element->getLabel() . "</label>"; } $output .= "<" . $element->getBalise(); if ($element->getId() != null and $element->getId() != "") { $output .= " id=\"" . $element->getId() . "\""; } if ($element->getName() != null and $element->getName() != "") { $output .= " name=\"" . $element->getName() . "\""; } $output .= " value=\"" . $element->getValue() . "\""; foreach ($element->getAttributes() as $k => $v) { $output .= " {$k}=\"{$v}\""; } $output .= "/>"; if ($isLabel and ($element->getAttributes()['type'] == 'radio' or $element->getAttributes()['type'] == 'checkbox')) { $output .= "<label for=\"" . $label . "\">" . $element->getLabel() . "</label>"; } } else { if ($isLabel and (strtolower($element->getBalise()) == "select" or strtolower($element->getBalise()) == "textarea")) { $output .= "<label for=\"" . $label . "\">" . $element->getLabel() . "</label>"; } $output .= "<" . $element->getBalise(); if ($element->getId() != null and $element->getId() != "") { $output .= " id=\"" . $element->getId() . "\""; } if ($element->getName() != null and $element->getName() != "") { $output .= " name=\"" . $element->getName() . "\""; } $output .= " value=\"" . $element->getValue() . "\""; foreach ($element->getAttributes() as $k => $v) { $output .= " {$k}=\"{$v}\""; } $output .= ">"; if (sizeof($element->getElements()) > 0) { foreach ($element->getElements() as $v) { $output .= self::process_form_elements($v); } } else { if (strtolower($element->getBalise()) != "textarea") { $output .= $element->getLabel(); } else { $output .= $element->getValue(); } } $output .= "</" . $element->getBalise() . ">"; } return $output; }