select() public method

Create a select box field.
public select ( string $name, array $list = [], string $selected = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$list array
$selected string
$options array
return Illuminate\Support\HtmlString
Exemplo n.º 1
0
    public function selection($nom, $list = [], $selected = null, $label = null)
    {
        return sprintf('
			<div class="form-group" style="width:200px;">
				%s
				%s
			</div>', $label ? $this->label($nom, $label, ['class' => 'control-label']) : '', parent::select($nom, $list, $selected, ['class' => 'form-control']));
    }
 public function select($name, $list = [], $selected = null, $options = [])
 {
     return sprintf('
     <div class="input-field col l6 s8 offset-l3 offset-s2">
         %s
         %s
     </div>', parent::select($name, $list, $selected, $options), parent::label($name, null, []));
 }
Exemplo n.º 3
0
 /**
  * Create a select box field.
  *
  * @param  string  $name
  * @param  string  $label
  * @param  array   $list
  * @param  string  $selected
  * @param  array   $options
  * @return string
  */
 public function select($name, $label = null, $list = [], $selected = null, array $options = [], $extra = null)
 {
     $label = $label === false ? $label : $this->getLabelTitle($label, $name);
     $options = $this->getFieldOptions($options, $name);
     $inputElement = $this->form->select($name, $list, $selected, $options);
     $wrapperOptions = $this->isHorizontal() ? ['class' => $this->getRightColumnClass()] : [];
     $wrapperElement = '<div' . $this->html->attributes($wrapperOptions) . '>' . $inputElement . $this->getFieldError($name) . '</div>';
     return $label ? $this->getFormGroupWithLabel($name, $label, $wrapperElement, $extra) : $this->getFormGroup($name, $wrapperElement, $extra);
 }
Exemplo n.º 4
0
 /**
  * Create a select box field.
  *
  * @param  string  $name
  * @param  string  $label
  * @param  array   $list
  * @param  string  $selected
  * @param  array   $options
  * @return string
  */
 public function select($name, $label = null, $list = [], $selected = null, array $options = [])
 {
     $label = $this->getLabelTitle($label, $name);
     $options = $this->getFieldOptions($options);
     $wrapperOptions = [];
     if ($this->getType() === Type::HORIZONTAL) {
         $wrapperOptions = ['class' => $this->getRightColumnClass()];
     }
     $inputElement = $this->form->select($name, $list, $selected, $options);
     $groupElement = '<div ' . $this->html->attributes($wrapperOptions) . '>' . $inputElement . $this->getFieldError($name) . '</div>';
     return $this->getFormGroupWithLabel($name, $label, $groupElement);
 }
Exemplo n.º 5
0
 /**
  * Build all control with the css class, label, and input.
  *
  * @param       $type
  * @param       $name
  * @param null  $value
  * @param array $attributes
  * @param array $options
  * @return string
  */
 public function buildControl($type, $name, $value = null, $attributes = [], $options = [])
 {
     switch ($type) {
         case 'select':
             $options = ['' => config('field-builder.select')] + $options;
             return $this->form->select($name, $options, $value, $attributes);
         case 'password':
             return $this->form->password($name, $attributes);
         case 'checkbox':
             return $this->form->checkbox($name, $value, isset($attributes['checked']), $attributes);
         case 'textarea':
             return $this->form->textarea($name, $value, $attributes);
         case 'number':
             return $this->form->number($name, $value, $attributes);
         case 'radio':
             return $this->form->radio($name, $value, $attributes);
         case 'email':
             return $this->form->email($name, $value, $attributes);
         default:
             return $this->form->input($type, $name, $value, $attributes);
     }
 }
Exemplo n.º 6
0
 /**
  * Create a select box field.
  *
  * @param string $name
  * @param array $list
  * @param string $selected
  * @param array $options
  * @return string 
  * @static 
  */
 public static function select($name, $list = array(), $selected = null, $options = array())
 {
     return \Collective\Html\FormBuilder::select($name, $list, $selected, $options);
 }
 /**
  * Create a plain select box field.
  *
  * @param  string $name
  * @param  array  $list
  * @param  string $selected
  * @param  array  $options
  *
  * @return string
  */
 public function plainSelect($name, $list = [], $selected = null, $options = [])
 {
     return parent::select($name, $list, $selected, $options);
 }
 /**
  * Create a select box field.
  *
  * @param  string $name
  * @param  array $list
  * @param  string $selected
  * @param  array $options
  * @return string
  */
 public function select($name, $list = [], $selected = null, $options = [])
 {
     return parent::select($name, $list, $selected, $this->appendErrors($name, $options));
 }
Exemplo n.º 9
0
 /**
  * @see Collective\Html\FormBuilder
  */
 public function select($name, $list = [], $selected = null, $options = [])
 {
     $options = $this->converter->convert(Helper::getFormAttribute($name)) + $options;
     return parent::select($name, $list, $selected, $options);
 }
Exemplo n.º 10
0
 public function select($name, $list = [], $selected = null, $options = [])
 {
     $options = $this->setOptionClasses($name, $options, ['form-control']);
     $controlHtml = parent::select($name, $list, $selected, $options);
     return $this->renderControl('select', $controlHtml, $name, '', $options);
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  * @param string $name
  * @param array  $list
  * @param null   $selected
  * @param array  $attributes
  * @return string
  */
 public function select($name, $list = array(), $selected = null, $attributes = array())
 {
     $attributes['class'] = isset($attributes['class']) ? self::FORM_CONTROL . ' ' . $attributes['class'] : self::FORM_CONTROL;
     return parent::select($name, $list, $selected, $attributes);
 }
Exemplo n.º 12
0
 /**
  * Create a select box field.
  *
  * @param  string  $name
  * @param  array   $list
  * @param  string  $selected
  * @param  array   $options
  *
  * @return string
  */
 public function select($name, $list = array(), $selected = null, $options = [])
 {
     $this->addErrorClass($name, $options);
     $tags['input'] = parent::select($name, $list, $selected, $options);
     $tags['error'] = $this->getErrorTag($name);
     return $this->buildTags($tags);
 }
Exemplo n.º 13
0
    $element .= '</select>';
    return form_group($element, $name);
});
Form::macro('submitBtn', function ($name = 'Enviar', $class = "btn btn-sm btn-success margin-top") {
    $btn = '<button type="submit" class="' . $class . '"> <span class="glyphicon glyphicon-save" aria-hidden="true"></span> ' . $name . ' </button>';
    return form_group($btn);
});
Form::macro('selectMultipleField', function ($name, $label = NULL, $options = [], $attributes = [], $value = NULL) {
    $attributes = array_merge($attributes, ['multiple' => true]);
    $element = Form::select($name . '[]', $options, $value ? $value : old($name), field_attributes($name, $attributes));
    return field_wrapper($name, $label, $element);
});
Form::macro('selectMultipleFieldClean', function ($name, $label = NULL, $options = [], $value = NULL, $attributes = []) {
    $attributes = array_merge($attributes, ['placeholder' => $label]);
    $attributes = array_merge($attributes, ['multiple' => true]);
    $element = Form::select($name . '[]', $options, $value ? $value : old($name), field_attributes($name, $attributes));
    return form_group($element, $name);
});
Form::macro('radioInline', function ($name, $label = NULL, array $options, $checked = NULL, $attributes = []) {
    $out = $label ? '<label for="' . $name . '">' . $label . '</label>' : '';
    $values = array_keys($options);
    $out .= '<div class="radio">';
    foreach ($values as $value) {
        $out .= '<label class="radio-inline">';
        $out .= Form::radio($name, $value, $checked ? $checked == $value : old($name) == $value, $attributes) . $options[$value];
        $out .= '</label>';
    }
    $out .= '</div>';
    return form_group($out, $name);
});
Form::macro('radioStack', function ($name, $label = NULL, array $options, $checked = NULL, $attributes = []) {