public function build() { $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 = "********"; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": $output = Form::password($this->name, $this->attributes); break; case "hidden": $output = ""; 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; }
<?php use Illuminate\Support\Facades\Form; Form::macro('textField', function ($name, $label = null, $value = null, $attributes = []) { $element = Form::text($name, $value, fieldAttributes($name, $attributes)); return fieldWrapper($name, $label, $element); }); Form::macro('passwordField', function ($name, $label = null, $attributes = []) { $element = Form::password($name, fieldAttributes($name, $attributes)); return fieldWrapper($name, $label, $element); }); Form::macro('textareaField', function ($name, $label = null, $value = null, $attributes = []) { $element = Form::textarea($name, $value, fieldAttributes($name, $attributes)); return fieldWrapper($name, $label, $element); }); Form::macro('selectField', function ($name, $label = null, $options, $value = null, $attributes = []) { $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes)); return fieldWrapper($name, $label, $element); }); Form::macro('selectMultipleField', function ($name, $label = null, $options, $value = null, $attributes = []) { $attributes = array_merge($attributes, ['multiple' => true]); $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes)); return fieldWrapper($name, $label, $element); }); Form::macro('checkboxField', function ($name, $label = null, $value = 1, $checked = null, $attributes = []) { $attributes = array_merge(['id' => 'id-field-' . $name], $attributes); $out = '<div class="checkbox'; $out .= fieldError($name) . '">'; $out .= '<label>'; $out .= Form::checkbox($name, $value, $checked, $attributes) . ' ' . $label; $out .= '</div>';
/** * Create a HTML password input element. * * @param string $name * @param string $label * @param array $attributes * @return string */ public function password($name, $label = '', $attributes = array()) { $attributes = $this->setAttributes($name, $attributes); $field = Form::password($name, $attributes); return $this->buildWrapper($field, $name, $label); }