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 $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
help(string $text = '', bool $show_help = true, string $icon = 'bi-info-circle')

Set help block for current field.

from  Field
string
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
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
disable() deprecated

Set field as disabled.

from  Field
disabled()

Set field as disabled.html 标准属性

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
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
searchable()

使用 layui 自带的 lay-search 来对搜索进行支持

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.

canCheckAll()

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

inline()

Draw inline checkboxes.

stacked()

Draw stacked checkboxes.

Details

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

Field constructor.

Parameters

$column
array $arguments

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

Set form element name.

Parameters

string $name

Return Value

$this

at line 33
void fill(array $data)

No description

Parameters

array $data

Return Value

void

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

custom format form column data when edit.

Parameters

Closure $call

Return Value

$this

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

No description

Parameters

array $data

Return Value

void

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

No description

Parameters

Form $form

Return Value

$this

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

Set width for field and label.

Parameters

int $field
int $label

Return Value

$this

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

Set options.

Parameters

array $options

Return Value

$this

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

Set the field option checked.

Parameters

array $checked

Return Value

$this

in Field at line 406
$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 423
$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 440
$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 454
array|mixed getValidationMessages()

Get validation messages for the field.

Return Value

array|mixed

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

Set validation messages for column.

Parameters

string $key
array $messages

Return Value

$this

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

Set field validator.

Parameters

callable $validator

Return Value

$this

in Field at line 503
string getErrorKey()

Get key for error message.

Return Value

string

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

Set key for error message.

Parameters

string $key

Return Value

$this

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

Set or get value of the field.

Parameters

null $value

Return Value

mixed

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

Set or get data.

Parameters

array $data

Return Value

$this

at line 68
$this default($default)

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

Parameters

$default

Return Value

$this

in Field at line 575
mixed getDefault()

Get default value.

Return Value

mixed

in Field at line 592
Field help(string $text = '', bool $show_help = true, string $icon = 'bi-info-circle')

Set help block for current field.

Parameters

string $text
bool $show_help
string $icon

Return Value

Field

in Field at line 604
string column()

Get column of the field.

Return Value

string

in Field at line 614
string label()

Get label of the field.

Return Value

string

in Field at line 624
mixed original()

Get original value of the field.

Return Value

mixed

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

Get validator for this field.

Parameters

array $input

Return Value

bool|Validator|mixed

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

Add html attributes to elements.

Parameters

array|string $attribute
mixed $value

Return Value

Field

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

Set Field style.

Parameters

string $attr
string $value

Return Value

$this

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

Set Field width.

Parameters

string $width

Return Value

$this

in Field at line 719
$this autofocus()

Set the field automatically get focus.

Return Value

$this

in Field at line 729
$this readonly()

Set the field as readonly mode.

此属性不适用于 select

Return Value

$this

in Field at line 742
Field disable() deprecated

deprecated 4.2

Set field as disabled.

Return Value

Field

See also

disabled()

in Field at line 752
Field disabled()

Set field as disabled.html 标准属性

Return Value

Field

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

Set field placeholder.

Parameters

string $placeholder

Return Value

$this

in Field at line 776
string getPlaceholder()

Get placeholder.

Return Value

string

in MultipleSelect at line 88
mixed prepare($value)

Prepare for a field value before update or insert.

Parameters

$value

Return Value

mixed

in Field at line 798
$this disableHorizontal()

No description

Return Value

$this

in Field at line 808
array getViewElementClasses()

No description

Return Value

array

in Field at line 830
array getElementClass()

Get element class.

Return Value

array

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

Set form element class.

Parameters

string|array $class

Return Value

$this

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

Add the element class.

Parameters

$class

Return Value

$this

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

Remove element class.

Parameters

$class

Return Value

$this

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

reset field className.

Parameters

string $className
string $resetClassName

Return Value

$this

in Field at line 909
string getLabelClass()

No description

Return Value

string

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

No description

Parameters

array $labelClass

Return Value

Field

in Field at line 931
array variables()

Get the view variables of this field.

Return Value

array

in Field at line 956
string getView()

Get view of this field.

Return Value

string

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

Set view of current field.

Parameters

string $view

Return Value

string

in Field at line 981
string getType()

No description

Return Value

string

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

To set this field should render or not.

Parameters

bool $display

Return Value

$this

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

No description

Parameters

Closure $callback

Return Value

Field

at line 77
Factory|View|string render()

No description

Return Value

Factory|View|string

in Field at line 1035
string __toString()

No description

Return Value

string

Exceptions

Throwable

in Field at line 1045
string getRules()

Get field validation rules.

Return Value

string

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

Format the name of the field.

Parameters

string $column

Return Value

array|mixed|string

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

Format the field column name.

Parameters

string $column

Return Value

mixed

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

Format the field element id.

Parameters

string|array $column

Return Value

string|array

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

Format the label value.

Parameters

array $arguments

Return Value

string

in Field at line 1174
protected formatValue()

Format value by passing custom formater.

in Field at line 1187
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 1197
protected addRequiredAttributeFromRules()

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

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

Format validation rules.

Parameters

array|string $rules

Return Value

array

in Field at line 1233
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 1256
protected void removeRule(string $rule)

Remove a specific rule by keyword.

Parameters

string $rule

Return Value

void

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

Sanitize input data.

Parameters

array $input
string $column

Return Value

array

in Field at line 1294
protected string formatAttributes()

Format the field attributes.

Return Value

string

in Field at line 1310
protected mixed getElementClassString()

Get element class string.

Return Value

mixed

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

Get element class selector.

Return Value

string|array

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

Get element class.

Parameters

bool $default

Return Value

string

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

Set form group class.

Parameters

string|array $class

Return Value

Field

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

Add variables to field view.

Parameters

array $variables

Return Value

Field

in Field at line 1403
protected bool shouldRender()

If this field should render.

Return Value

bool

in Select at line 99
$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 115
$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 153
Select searchable()

使用 layui 自带的 lay-search 来对搜索进行支持

Return Value

Select

in Select at line 171
$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 102
protected string getOtherKey()

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

Return Value

string

Exceptions

Exception

at line 91
Checkbox canCheckAll()

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

Return Value

Checkbox

at line 102
Checkbox inline()

Draw inline checkboxes.

Return Value

Checkbox

at line 113
Checkbox stacked()

Draw stacked checkboxes.

Return Value

Checkbox