class Checkbox extends MultipleSelect

Traits

Macroable

Constants

FILE_DELETE_FLAG

FILE_SORT_FLAG

Properties

array|Closure $creationRules

The validation rules for creation.

from  Field
array|Closure $updateRules

The validation rules for updates.

from  Field
bool $isJsonType from  Field
protected array|string $id

Element id.

from  Field
protected mixed $value

Element value.

from  Field
protected mixed $data

Data of all original columns of value.

from  Field
protected mixed $original

Field original value.

from  Field
protected array $default 默认值
protected string $label

Element label.

from  Field
protected string|array $column

Column name.

from  Field
protected string $elementName

Form element name.

from  Field
protected array $elementClass

Form element classes.

from  Field
protected array $variables

Variables of elements.

from  Field
protected array $options

Options for specify elements.

from  Field
protected array $checked

Checked for specify elements.

from  Field
protected array|Closure $rules

Validation rules.

from  Field
protected Closure $validator from  Field
protected array $validationMessages

Validation messages.

from  Field
protected array $attributes

Element attributes.

from  Field
protected Form $form

Parent form.

from  Field
protected string $view

View for field to render.

from  Field
protected array $help

Help block.

from  Field
protected mixed $errorKey

Key for errors.

from  Field
protected $placeholder from  Select
protected bool $showHelp from  Field
protected array $width

Width for label and field.

from  Field
protected bool $horizontal

If the form horizontal layout.

from  Field
protected Closure $customFormat

column data format.

from  Field
protected bool $display from  Field
protected array $labelClass from  Field
protected array $groupClass from  Field
protected Closure $callback from  Field
protected array $groups from  Select
protected array $config from  Select
protected string $otherKey

Other key for many-to-many relation.

from  MultipleSelect
protected bool $inline 是否行内显示
protected bool $canCheckAll 是否可以全选

Methods

__construct($column = '', array $arguments = [])

Field constructor.

from  Field
$this
setElementName(string $name)

Set form element name.

from  Field
void
fill(array $data)

No description

$this
customFormat(Closure $call)

custom format form column data when edit.

from  Field
void
setOriginal(array $data)

No description

$this
setForm(Form $form = null)

No description

from  Field
$this
setWidth(int $field = 8, int $label = 2)

Set width for field and label.

from  Field
$this
options(array $options = [])

Set options.

$this
checked(array $checked = [])

Set the field option checked.

from  Field
$this
rules(array $rules = [], array $messages = [])

Set the validation rules for the field.

from  Field
$this
updateRules(array|callable $rules = [], array $messages = [])

Set the update validation rules for the field.

from  Field
$this
creationRules(array|callable $rules = [], array $messages = [])

Set the creation validation rules for the field.

from  Field
array|mixed
getValidationMessages()

Get validation messages for the field.

from  Field
$this
setValidationMessages(string $key, array $messages)

Set validation messages for column.

from  Field
$this
validator(callable $validator)

Set field validator.

from  Field
string
getErrorKey()

Get key for error message.

from  Field
$this
setErrorKey(string $key)

Set key for error message.

from  Field
mixed
value(null $value = null)

Set or get value of the field.

from  Field
$this
data(array $data = null)

Set or get data.

from  Field
$this
default($default)

默认值, 当没有数据做填充的时候会取这个默认值(null 值的时候)

mixed
getDefault()

Get default value.

from  Field
$this
help(string $text = '', string $icon = 'fa-info-circle')

Set help block for current field.

from  Field
string|array
column()

Get column of the field.

from  Field
string
label()

Get label of the field.

from  Field
mixed
original()

Get original value of the field.

from  Field
bool|Validator|mixed
getValidator(array $input)

Get validator for this field.

from  Field
$this
attribute(array|string $attribute, mixed $value = null)

Add html attributes to elements.

from  Field
$this
style(string $attr, string $value)

Set Field style.

from  Field
$this
width(string $width)

Set Field width.

from  Field
$this
autofocus()

Set the field automatically get focus.

from  Field
$this
readonly()

Set the field as readonly mode.

from  Field
$this
disable()

Set field as disabled.

from  Field
$this
placeholder(string $placeholder = '')

Set field placeholder.

from  Field
string
getPlaceholder()

Get placeholder.

from  Field
mixed
prepare($value)

Prepare for a field value before update or insert.

$this
disableHorizontal()

No description

from  Field
array
getViewElementClasses()

No description

from  Field
array
getElementClass()

Get element class.

from  Field
$this
setElementClass(string|array $class)

Set form element class.

from  Field
$this
addElementClass($class)

Add the element class.

from  Field
$this
removeElementClass($class)

Remove element class.

from  Field
$this
resetElementClassName(string $className, string $resetClassName)

reset field className.

from  Field
string
getLabelClass()

No description

from  Field
setLabelClass(array $labelClass)

No description

from  Field
array
variables()

Get the view variables of this field.

from  Field
string
getView()

Get view of this field.

from  Field
string
setView(string $view)

Set view of current field.

from  Field
string
getType()

No description

from  Field
$this
setDisplay(bool $display)

To set this field should render or not.

from  Field
with(Closure $callback)

No description

from  Field
Factory|View|string
render()

No description

string
__toString()

No description

from  Field
string
getRules()

Get field validation rules.

from  Field
array|mixed|string
formatName(string $column)

Format the name of the field.

from  Field
array
skeleton()

No description

mixed
formatColumn(string $column = '')

Format the field column name.

from  Field
string|array
formatId(string|array $column)

Format the field element id.

from  Field
string
formatLabel(array $arguments = [])

Format the label value.

from  Field
formatValue()

Format value by passing custom formater.

from  Field
addRequiredAttribute(array $rules)

Add required attribute to current field if has required rule, except file and image fields.

from  Field
addRequiredAttributeFromRules()

If has required rule, add required attribute to this field.

from  Field
array
formatRules(array|string $rules)

Format validation rules.

from  Field
array|Closure
mergeRules(string|array|Closure $input, string|array $original)

No description

from  Field
void
removeRule(string $rule)

Remove a specific rule by keyword.

from  Field
array
sanitizeInput(array $input, string $column)

Sanitize input data.

from  Field
string
formatAttributes()

Format the field attributes.

from  Field
mixed
getElementClassString()

Get element class string.

from  Field
string|array
getElementClassSelector()

Get element class selector.

from  Field
string
getGroupClass(bool $default = false)

Get element class.

from  Field
setGroupClass(string|array $class)

Set form group class.

from  Field
addVariables(array $variables = [])

Add variables to field view.

from  Field
bool
shouldRender()

If this field should render.

from  Field
$this
groups(array $groups)

Set option groups.

from  Select
$this
model(string $model, string $idField = 'id', string $textField = 'name')

Load options from current selected resource(s).

from  Select
$this
config(string $key, mixed $val)

Set config for select2.

from  Select
string
getOtherKey()

Get other key for this many-to-many relation.

$this
canCheckAll()

Add a checkbox above this component, so you can select all checkboxes by click on it.

$this
inline()

Draw inline checkboxes.

$this
stacked()

Draw stacked checkboxes.

Details

in Field at line 224
__construct($column = '', array $arguments = [])

Field constructor.

Parameters

$column
array $arguments

in Field at line 240
$this setElementName(string $name)

Set form element name.

Parameters

string $name

Return Value

$this

at line 32
void fill(array $data)

No description

Parameters

array $data

Return Value

void

in Field at line 278
$this customFormat(Closure $call)

custom format form column data when edit.

Parameters

Closure $call

Return Value

$this

in MultipleSelect at line 55
void setOriginal(array $data)

No description

Parameters

array $data

Return Value

void

in Field at line 310
$this setForm(Form $form = null)

No description

Parameters

Form $form

Return Value

$this

in Field at line 325
$this setWidth(int $field = 8, int $label = 2)

Set width for field and label.

Parameters

int $field
int $label

Return Value

$this

at line 45
$this options(array $options = [])

Set options.

Parameters

array $options

Return Value

$this

in Field at line 360
$this checked(array $checked = [])

Set the field option checked.

Parameters

array $checked

Return Value

$this

in Field at line 379
$this rules(array $rules = [], array $messages = [])

Set the validation rules for the field.

Parameters

array $rules
array $messages

Return Value

$this

in Field at line 396
$this updateRules(array|callable $rules = [], array $messages = [])

Set the update validation rules for the field.

Parameters

array|callable $rules
array $messages

Return Value

$this

in Field at line 413
$this creationRules(array|callable $rules = [], array $messages = [])

Set the creation validation rules for the field.

Parameters

array|callable $rules
array $messages

Return Value

$this

in Field at line 427
array|mixed getValidationMessages()

Get validation messages for the field.

Return Value

array|mixed

in Field at line 450
$this setValidationMessages(string $key, array $messages)

Set validation messages for column.

Parameters

string $key
array $messages

Return Value

$this

in Field at line 464
$this validator(callable $validator)

Set field validator.

Parameters

callable $validator

Return Value

$this

in Field at line 476
string getErrorKey()

Get key for error message.

Return Value

string

in Field at line 488
$this setErrorKey(string $key)

Set key for error message.

Parameters

string $key

Return Value

$this

in Field at line 502
mixed value(null $value = null)

Set or get value of the field.

Parameters

null $value

Return Value

mixed

in Field at line 518
$this data(array $data = null)

Set or get data.

Parameters

array $data

Return Value

$this

at line 66
$this default($default)

默认值, 当没有数据做填充的时候会取这个默认值(null 值的时候)

Parameters

$default

Return Value

$this

in Field at line 548
mixed getDefault()

Get default value.

Return Value

mixed

in Field at line 565
$this help(string $text = '', string $icon = 'fa-info-circle')

Set help block for current field.

Parameters

string $text
string $icon

Return Value

$this

in Field at line 577
string|array column()

Get column of the field.

Return Value

string|array

in Field at line 587
string label()

Get label of the field.

Return Value

string

in Field at line 597
mixed original()

Get original value of the field.

Return Value

mixed

in Field at line 609
bool|Validator|mixed getValidator(array $input)

Get validator for this field.

Parameters

array $input

Return Value

bool|Validator|mixed

in Field at line 650
$this attribute(array|string $attribute, mixed $value = null)

Add html attributes to elements.

Parameters

array|string $attribute
mixed $value

Return Value

$this

in Field at line 670
$this style(string $attr, string $value)

Set Field style.

Parameters

string $attr
string $value

Return Value

$this

in Field at line 682
$this width(string $width)

Set Field width.

Parameters

string $width

Return Value

$this

in Field at line 692
$this autofocus()

Set the field automatically get focus.

Return Value

$this

in Field at line 702
$this readonly()

Set the field as readonly mode.

Return Value

$this

in Field at line 712
$this disable()

Set field as disabled.

Return Value

$this

in Field at line 724
$this placeholder(string $placeholder = '')

Set field placeholder.

Parameters

string $placeholder

Return Value

$this

in Field at line 736
string getPlaceholder()

Get placeholder.

Return Value

string

in MultipleSelect at line 86
mixed prepare($value)

Prepare for a field value before update or insert.

Parameters

$value

Return Value

mixed

in Field at line 758
$this disableHorizontal()

No description

Return Value

$this

in Field at line 768
array getViewElementClasses()

No description

Return Value

array

in Field at line 790
array getElementClass()

Get element class.

Return Value

array

in Field at line 802
$this setElementClass(string|array $class)

Set form element class.

Parameters

string|array $class

Return Value

$this

in Field at line 816
$this addElementClass($class)

Add the element class.

Parameters

$class

Return Value

$this

in Field at line 832
$this removeElementClass($class)

Remove element class.

Parameters

$class

Return Value

$this

in Field at line 857
$this resetElementClassName(string $className, string $resetClassName)

reset field className.

Parameters

string $className
string $resetClassName

Return Value

$this

in Field at line 869
string getLabelClass()

No description

Return Value

string

in Field at line 879
Field setLabelClass(array $labelClass)

No description

Parameters

array $labelClass

Return Value

Field

in Field at line 891
array variables()

Get the view variables of this field.

Return Value

array

in Field at line 916
string getView()

Get view of this field.

Return Value

string

in Field at line 934
string setView(string $view)

Set view of current field.

Parameters

string $view

Return Value

string

in Field at line 941
string getType()

No description

Return Value

string

in Field at line 954
$this setDisplay(bool $display)

To set this field should render or not.

Parameters

bool $display

Return Value

$this

in Field at line 966
Field with(Closure $callback)

No description

Parameters

Closure $callback

Return Value

Field

at line 75
Factory|View|string render()

No description

Return Value

Factory|View|string

in Field at line 995
string __toString()

No description

Return Value

string

Exceptions

Throwable

in Field at line 1005
string getRules()

Get field validation rules.

Return Value

string

in Field at line 1051
array|mixed|string formatName(string $column)

Format the name of the field.

Parameters

string $column

Return Value

array|mixed|string

at line 84
array skeleton()

No description

Return Value

array

in Field at line 1097
protected mixed formatColumn(string $column = '')

Format the field column name.

Parameters

string $column

Return Value

mixed

in Field at line 1115
protected string|array formatId(string|array $column)

Format the field element id.

Parameters

string|array $column

Return Value

string|array

in Field at line 1127
protected string formatLabel(array $arguments = [])

Format the label value.

Parameters

array $arguments

Return Value

string

in Field at line 1139
protected formatValue()

Format value by passing custom formater.

in Field at line 1152
protected addRequiredAttribute(array $rules)

Add required attribute to current field if has required rule, except file and image fields.

Parameters

array $rules

in Field at line 1162
protected addRequiredAttributeFromRules()

If has required rule, add required attribute to this field.

in Field at line 1183
protected array formatRules(array|string $rules)

Format validation rules.

Parameters

array|string $rules

Return Value

array

in Field at line 1198
protected array|Closure mergeRules(string|array|Closure $input, string|array $original)

No description

Parameters

string|array|Closure $input
string|array $original

Return Value

array|Closure

in Field at line 1221
protected void removeRule(string $rule)

Remove a specific rule by keyword.

Parameters

string $rule

Return Value

void

in Field at line 1244
protected array sanitizeInput(array $input, string $column)

Sanitize input data.

Parameters

array $input
string $column

Return Value

array

in Field at line 1259
protected string formatAttributes()

Format the field attributes.

Return Value

string

in Field at line 1275
protected mixed getElementClassString()

Get element class string.

Return Value

mixed

in Field at line 1298
protected string|array getElementClassSelector()

Get element class selector.

Return Value

string|array

in Field at line 1322
protected string getGroupClass(bool $default = false)

Get element class.

Parameters

bool $default

Return Value

string

in Field at line 1334
Field setGroupClass(string|array $class)

Set form group class.

Parameters

string|array $class

Return Value

Field

in Field at line 1353
protected Field addVariables(array $variables = [])

Add variables to field view.

Parameters

array $variables

Return Value

Field

in Field at line 1368
protected bool shouldRender()

If this field should render.

Return Value

bool

in Select at line 97
$this groups(array $groups)

Set option groups.

eg: $group = [ [ 'label' => 'xxxx', 'options' => [ 1 => 'foo', 2 => 'bar', ... ], ... ]

Parameters

array $groups

Return Value

$this

in Select at line 113
$this model(string $model, string $idField = 'id', string $textField = 'name')

Load options from current selected resource(s).

Parameters

string $model
string $idField
string $textField

Return Value

$this

in Select at line 157
$this config(string $key, mixed $val)

Set config for select2.

all configurations see https://select2.org/configuration/options-api

Parameters

string $key
mixed $val

Return Value

$this

in MultipleSelect at line 100
protected string getOtherKey()

Get other key for this many-to-many relation.

Return Value

string

Exceptions

Exception

at line 97
$this canCheckAll()

Add a checkbox above this component, so you can select all checkboxes by click on it.

Return Value

$this

at line 109
$this inline()

Draw inline checkboxes.

Return Value

$this

at line 121
$this stacked()

Draw stacked checkboxes.

Return Value

$this