checkbox() public method

Create a checkbox input field.
public checkbox ( string $name, mixed $value = 1, boolean $checked = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value mixed
$checked boolean
$options array
return Illuminate\Support\HtmlString
Exemplo n.º 1
0
 /**
  * Create a Bootstrap checkbox input.
  *
  * @param  string   $name
  * @param  string   $label
  * @param  string   $value
  * @param  bool     $checked
  * @param  bool     $inline
  * @param  array    $options
  * @return string
  */
 public function checkbox($name, $label, $value, $checked = null, $inline = false, array $options = [])
 {
     $labelOptions = $inline ? ['class' => 'checkbox-inline'] : [];
     $inputElement = $this->form->checkbox($name, $value, $checked, $options);
     $labelElement = '<label ' . $this->html->attributes($labelOptions) . '>' . $inputElement . $label . '</label>';
     return $inline ? $labelElement : '<div class="checkbox">' . $labelElement . '</div>';
 }
Exemplo n.º 2
0
    public function check($name, $label)
    {
        return sprintf('
			<div class="checkbox col-lg-12">
				<label>
			  	%s%s
			  </label>
			</div>', parent::checkbox($name), $label);
    }
 public function checkbox($name, $value = 1, $checked = null, $options = [])
 {
     $options['id'] = $name;
     return sprintf('
     <div class="input-field col l6 s8 offset-l3 offset-s2">
         %s
         %s
         %s
     </div>', parent::hidden($name, 0), parent::checkbox($name, $value, $checked, $options), parent::label($name, null, []));
 }
Exemplo n.º 4
0
    public function checkHorizontal($name, $label, $value)
    {
        return sprintf('
			<div class="form-group">
				<div class="checkbox">
					<label>
						%s%s
					</label>
				</div>
			</div>', parent::checkbox($name, $value), $label);
    }
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 checkbox input field.
  *
  * @param string $name
  * @param mixed $value
  * @param bool $checked
  * @param array $options
  * @return string 
  * @static 
  */
 public static function checkbox($name, $value = 1, $checked = null, $options = array())
 {
     return \Collective\Html\FormBuilder::checkbox($name, $value, $checked, $options);
 }
 /**
  * Create an inline checkbox input field.
  *
  * @param  string $name
  * @param  mixed  $value
  * @param  mixed  $label
  * @param  bool   $checked
  * @param  array  $options
  *
  * @return string
  */
 public function inlineCheckbox($name, $value = 1, $label = null, $checked = null, $options = [])
 {
     //Capture Bootstrap classes
     $class = $this->getClasses($name, $options);
     $class = $this->appendClassToOptions('checkbox-inline', $class);
     $object = parent::checkbox($name, $value, $checked, $options);
     return $this->wrapCheckable($label, $class, $object);
 }
Exemplo n.º 8
0
 /**
  * Add a checkbox column.
  *
  * @param  array $attributes
  * @return $this
  */
 public function addCheckbox(array $attributes = [])
 {
     $attributes = array_merge(['defaultContent' => '<input type="checkbox" ' . $this->html->attributes($attributes) . '/>', 'title' => $this->form->checkbox('', '', false, ['id' => 'dataTablesCheckbox']), 'data' => 'checkbox', 'name' => 'checkbox', 'orderable' => false, 'searchable' => false, 'exportable' => false, 'printable' => true, 'width' => '10px'], $attributes);
     $this->collection->push(new Column($attributes));
     return $this;
 }
Exemplo n.º 9
0
 public function checkbox($name, $value = 1, $checked = null, $options = [])
 {
     $additionalClasses = $this->usesBootstrap4() ? 'form-check-input' : '';
     $options = $this->setOptionClasses($name, $options, [$additionalClasses]);
     $label = $options['label'];
     $controlOptions = $this->getControlOptions(collect($options), ['form-control', 'placeholder']);
     $controlHtml = parent::checkbox($name, $value, $checked, $controlOptions->toArray()) . " {$label}";
     return $this->renderControl('checkbox', $controlHtml, $name, $value, $options);
 }
Exemplo n.º 10
0
 /**
  * Create an inline checkbox input field.
  *
  * @param  string $name
  * @param  mixed $value
  * @param  mixed $label
  * @param  bool $checked
  * @param  array $options
  *
  * @return string
  */
 public function inlineCheckbox($name, $value = 1, $label = null, $checked = null, $options = [])
 {
     $prefix = $value == 1 ? $this->hidden($name, '0') : '';
     $checkable = $prefix . parent::checkbox($name, $value, $checked, $options);
     return $this->wrapInlineCheckable($label, 'checkbox', $checkable);
 }
 /**
  * Create an inline checkbox
  *
  * @param  string  $name
  * @param  mixed   $value
  * @param  mixed   $label
  * @param  bool    $checked
  * @param  array   $options
  * @return string
  */
 public function inlineCheckbox($name, $value = 1, $label = null, $checked = null, $options = array())
 {
     return $this->wrapInlineCheckable($label, 'checkbox', parent::checkbox($name, $value, $checked, $options));
 }
Exemplo n.º 12
0
    $out = $label ? '<label for="' . $name . '">' . $label . '</label>' : '';
    $values = array_keys($options);
    foreach ($values as $value) {
        $out .= '<div class="radio">';
        $out .= '<label>';
        $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('checkboxField', function ($name, $label = NULL, $value = 1, $checked = NULL, $attributes = []) {
    $out = '<div class="checkbox';
    $out .= field_error($name) . '">';
    $out .= '<label>';
    $out .= Form::checkbox($name, $value, $checked ? $checked : old($name), $attributes) . $label;
    $out .= '</div>';
    return $out;
});
Form::macro('delete', function ($route, $id, $text = '', $tooltip = false, $icon = true) {
    $model = explode('.', $route);
    $model = ucfirst(substr($model[1], 0, -1));
    $tooltip = $tooltip ? $tooltip : 'Deletar ' . $model;
    $out = Form::open(['route' => [$route . '.destroy', $id], 'method' => 'DELETE', 'data-id' => $id, 'style' => 'display: inline-block']);
    $out .= '<button data-toggle="tooltip" data-placement="top" data-original-title="' . $tooltip . '" type="submit" data-id="' . $id . '" class="btn btn-danger btn-sm ' . ($icon ? 'btn-fw' : '') . '">';
    $out .= $icon ? '<i class="fa fa-times"></i> &nbsp;' . $text : $text;
    $out .= '</button>';
    $out .= Form::close();
    return $out;
});
Form::macro('undelete', function ($route, $id, $text = '', $tooltip = false) {