public function build() { $output = ""; $this->attributes["class"] = "form-control"; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = nl2br(htmlspecialchars($this->value)); } $output = "<div class='help-block'>" . $output . "</div>"; break; case "create": case "modify": $output = Form::file($this->db_name, $this->attributes); break; case "hidden": $output = Form::hidden($this->db_name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
/** * 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; }
public function build() { $this->path = $this->parseString($this->path); $this->web_path = $this->parseString($this->web_path); $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = nl2br(htmlspecialchars($this->value)); } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": if ($this->old_value) { $output .= '<div class="clearfix">'; $output .= link_to($this->web_path . $this->value, $this->value) . " "; $output .= Form::checkbox($this->name . '_remove', 1, (bool) Input::get($this->name . '_remove')) . " " . trans('rapyd::rapyd.delete') . " <br/>\n"; $output .= '</div>'; } $output .= Form::file($this->name, $this->attributes); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
/** * Create a HTML file input element. * * @param string $name * @param string $label * @param array $attributes * @return string */ public function file($name, $label, $attributes = array()) { $attributes = $this->setAttributes($name, $attributes); $field = Form::file($name, $attributes); return $this->buildWrapper($field, $name, $label); }