Ejemplo n.º 1
0
 /**
  * @param InputElement|Select|ToggleGroup $element
  *
  * @return string
  *
  * @since 2.0
  */
 public function renderInput($element)
 {
     if ($element instanceof Fieldset || $element instanceof Option || $element instanceof Optgroup || $element instanceof Radio) {
         return $element->render($this);
     }
     $element->setAttribute('class', trim($element->getAttribute('class') . ' form-control'));
     $name = $element->getName();
     $element->setAttribute('id', 'form_' . $name);
     $elementHtml = $element->render($this);
     $renderGroup = $element->getMeta('group', true);
     $content = '';
     if ($renderGroup) {
         $content = '<div class="form-group">';
     }
     if (trim($element->getLabel()) != '') {
         $content .= '<label for="' . $element->getAttribute('id') . '">' . $element->getLabel() . '</label>';
     }
     $content .= $elementHtml;
     if ($renderGroup) {
         $content .= '</div>';
     }
     return $content;
 }
Ejemplo n.º 2
0
 public static function forming()
 {
     $form = new Form("POST", Page::url("/forms"));
     $input = new InputElement("login", "Identifiant :", "Pierre");
     $form->addElement($input);
     $form->addElement(new ClosedElement("br"));
     // Balise, Name, Label, Value
     $input = new FormElement("select", "age", "Age :", 10);
     $input->addElement(new FormElement("option", "", "0-10", 0));
     $input->addElement(new FormElement("option", "", "10-20", 10));
     $input->addElement(new FormElement("option", "", "20-30", 20));
     $input->addElement(new FormElement("option", "", "30-40", 30));
     $input->addElement(new FormElement("option", "", "40-50", 40));
     $form->addElement($input);
     $form->addElement(new ClosedElement("br"));
     $input = new FormElement("label", null, "Age : ");
     $input->addClasses("label_input_checkbox_radio");
     $form->addElement($input);
     $input = new InputElement("mabox1", "0-10", 0, "checkbox", "mabox1");
     $input->setAttribute("checked", "checked");
     $form->addElement($input);
     $input = new InputElement("mabox2", "10-20", 10, "checkbox", "mabox2");
     $input->setAttribute("checked", "checked");
     $form->addElement($input);
     $input = new InputElement("mabox3", "20-30", 20, "checkbox", "mabox3");
     $form->addElement($input);
     $input = new InputElement("mabox4", "30-40", 30, "checkbox", "mabox4");
     $input->setAttribute("checked", "checked");
     $input->setAttribute("disabled", "disabled");
     $form->addElement($input);
     $input = new InputElement("mabox5", "40-50", 40, "checkbox", "mabox5");
     $input->setAttribute("disabled", "disabled");
     $form->addElement($input);
     $input = new FormElement("label", null, "Age : ");
     $input->addClasses("label_input_checkbox_radio");
     $form->addElement($input);
     $input = new InputElement("monradio", "0-10", 0, "radio", "monradio1");
     $input->setAttribute("checked", "checked");
     $form->addElement($input);
     $input = new InputElement("monradio", "10-20", 10, "radio", "monradio2");
     $form->addElement($input);
     $input = new InputElement("monradio", "20-30", 20, "radio", "monradio3");
     $form->addElement($input);
     $input = new InputElement("monradio", "30-40", 30, "radio", "monradio4");
     $form->addElement($input);
     $input = new InputElement("monradio", "40-50", 40, "radio", "monradio5");
     $form->addElement($input);
     $input = new FormElement("textarea", "description", t("Description : "), "Test");
     $input->setAttribute("row", 6);
     $input->setAttribute("col", 18);
     $input->addClasses("actualite_area_text");
     $form->addElement($input);
     $form->addElement(new ClosedElement("br"));
     $input = new InputElement("monbutton", null, "Test JS", "button");
     $input->setAttribute("onclick", "alert('Test JS OK');");
     $form->addElement($input);
     $theme = new Theme();
     $theme->process_form($form);
     $theme->process_theme();
 }