public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->description;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             foreach ($this->options as $val => $label) {
                 $this->checked = (!is_null($this->value) and $this->value == $val);
                 $output .= Form::radio($this->name, $val, $this->checked) . ' ' . $label . $this->separator;
             }
             $output .= $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #2
0
 /**
  * Make field HTML from field array
  *
  * @param  array  $field
  * @return string
  */
 private function makeField($field)
 {
     $output = '';
     //combine additional input attributes
     $input_attributes = array('class' => $field['input-class']);
     $input_attributes = array_merge($input_attributes, $field['input-attributes']);
     //
     //TEXT
     if ($field['type'] == "text") {
         $output .= Form::text($field['name'], $field['value'], $input_attributes);
     }
     //TEXTAREA
     if ($field['type'] == "textarea") {
         $output .= Form::textarea($field['name'], $field['value'], $input_attributes);
     }
     //PASSWORD
     if ($field['type'] == "password") {
         $output .= Form::password($field['name'], $field['value'], $input_attributes);
     }
     //SELECT
     if ($field['type'] == "select") {
         $output .= Form::select($field['name'], $field['options'], $field['value'], $input_attributes);
     }
     //CHECKBOXES
     if ($field['type'] == "checkbox") {
         foreach ($field['options'] as $option_key => $option_value) {
             $output .= '<label class="checkbox">';
             $checked = null;
             if (is_array($field['value']) && in_array($option_key, $field['value'])) {
                 $checked = true;
             }
             $output .= Form::checkbox($field['name'], $option_key, $checked);
             $output .= $option_value;
             $output .= '</label>';
         }
     }
     //RADIO
     if ($field['type'] == "radio") {
         foreach ($field['options'] as $option_key => $option_value) {
             $output .= '<label class="radio">';
             $checked = false;
             if ($option_key == $field['value']) {
                 $checked = true;
             }
             $output .= Form::radio($field['name'], $option_key, $checked);
             $output .= $option_value;
             $output .= '</label>';
         }
     }
     //FILE
     if ($field['type'] == "file") {
         $output .= Form::file($field['name'], $input_attributes);
     }
     //return
     return $output;
 }
Example #3
0
 /**
  * Create a HTML radio input element.
  *
  * @param  string  $name
  * @param  string  $value
  * @param  bool    $checked
  * @param  array   $attributes
  * @return string
  */
 public function radio($name, $value = '1', $checked = false, $attributes = array())
 {
     $checked = $this->calculateValue($name, $checked, $value);
     $attributes = $this->setAttributes($name, $attributes);
     return Form::radio($name, $value, $checked, $attributes);
 }