Field
class Field implements Renderable
Class Field.
Traits
Constants
FILE_DELETE_FLAG |
|
FILE_SORT_FLAG |
|
Properties
array|Closure | $creationRules | The validation rules for creation. |
|
array|Closure | $updateRules | The validation rules for updates. |
|
bool | $isJsonType | ||
protected array|string | $id | Element id. |
|
protected mixed | $value | Element value. |
|
protected mixed | $data | Data of all original columns of value. |
|
protected mixed | $original | Field original value. |
|
protected mixed | $default | Field default value. |
|
protected string | $label | Element label. |
|
protected string|array | $column | Column name. |
|
protected string | $elementName | Form element name. |
|
protected array | $elementClass | Form element classes. |
|
protected array | $variables | Variables of elements. |
|
protected array | $options | Options for specify elements. |
|
protected array | $checked | Checked for specify elements. |
|
protected array|Closure | $rules | Validation rules. |
|
protected Closure | $validator | ||
protected array | $validationMessages | Validation messages. |
|
protected array | $attributes | Element attributes. |
|
protected Form | $form | Parent form. |
|
protected string | $view | View for field to render. |
|
protected array | $help | Help block. |
|
protected mixed | $errorKey | Key for errors. |
|
protected string|array | $placeholder | Placeholder for this field. |
|
protected bool | $showHelp | ||
protected array | $width | Width for label and field. |
|
protected bool | $horizontal | If the form horizontal layout. |
|
protected Closure | $customFormat | column data format. |
|
protected bool | $display | ||
protected array | $labelClass | ||
protected array | $groupClass | ||
protected Closure | $callback |
Methods
Field constructor.
Set form element name.
Fill data to the field.
Set original value to the field.
Set width for field and label.
Set the field options.
Set the field option checked.
Set the validation rules for the field.
Set the update validation rules for the field.
Set the creation validation rules for the field.
Get validation messages for the field.
Set validation messages for column.
Set field validator.
Get key for error message.
Set key for error message.
Set or get value of the field.
Set or get data.
Set default value for field.
Get default value.
Set help block for current field.
Get column of the field.
Get label of the field.
Get original value of the field.
Get validator for this field.
Set Field style.
Set Field width.
Set the field automatically get focus.
Set the field as readonly mode.
Set field placeholder.
Get placeholder.
Prepare for a field value before update or insert.
No description
No description
Get element class.
Set form element class.
Add the element class.
Remove element class.
reset field className.
No description
No description
Get the view variables of this field.
Get view of this field.
Set view of current field.
No description
To set this field should render or not.
Render this filed.
No description
Get field validation rules.
Format the name of the field.
Format the field column name.
Format the field element id.
Format the label value.
Format value by passing custom formater.
Add required
attribute to current field if has required rule,
except file and image fields.
If has required
rule, add required attribute to this field.
Format validation rules.
Remove a specific rule by keyword.
Sanitize input data.
Format the field attributes.
Get element class string.
Get element class selector.
Get element class.
Set form group class.
Add variables to field view.
If this field should render.
Details
at line 251
__construct($column = '', array $arguments = [])
Field constructor.
at line 267
$this
setElementName(string $name)
Set form element name.
at line 281
void
fill(array $data)
Fill data to the field.
at line 305
$this
customFormat(Closure $call)
custom format form column data when edit.
at line 319
void
setOriginal(array $data)
Set original value to the field.
at line 337
$this
setForm(Form $form = null)
No description
at line 352
$this
setWidth(int $field = 8, int $label = 2)
Set width for field and label.
at line 369
$this
options(array $options = [])
Set the field options.
at line 387
$this
checked(array $checked = [])
Set the field option checked.
at line 406
$this
rules(array $rules = [], array $messages = [])
Set the validation rules for the field.
at line 423
$this
updateRules(array|callable $rules = [], array $messages = [])
Set the update validation rules for the field.
at line 440
$this
creationRules(array|callable $rules = [], array $messages = [])
Set the creation validation rules for the field.
at line 454
array|mixed
getValidationMessages()
Get validation messages for the field.
at line 477
$this
setValidationMessages(string $key, array $messages)
Set validation messages for column.
at line 491
$this
validator(callable $validator)
Set field validator.
at line 503
string
getErrorKey()
Get key for error message.
at line 515
$this
setErrorKey(string $key)
Set key for error message.
at line 529
mixed
value(null $value = null)
Set or get value of the field.
at line 545
$this
data(array $data = null)
Set or get data.
at line 563
$this
default($default)
Set default value for field.
at line 575
mixed
getDefault()
Get default value.
at line 592
Field
help(string $text = '', bool $show_help = true, string $icon = 'bi-info-circle')
Set help block for current field.
at line 604
string
column()
Get column of the field.
at line 614
string
label()
Get label of the field.
at line 624
mixed
original()
Get original value of the field.
at line 636
bool|Validator|mixed
getValidator(array $input)
Get validator for this field.
at line 677
Field
attribute(array|string $attribute, mixed $value = null)
Add html attributes to elements.
at line 697
$this
style(string $attr, string $value)
Set Field style.
at line 709
$this
width(string $width)
Set Field width.
at line 719
$this
autofocus()
Set the field automatically get focus.
at line 729
$this
readonly()
Set the field as readonly mode.
此属性不适用于 select
at line 742
Field
disable()
deprecated
deprecated
Set field as disabled.
at line 752
Field
disabled()
Set field as disabled.html 标准属性
at line 764
$this
placeholder(string $placeholder = '')
Set field placeholder.
at line 776
string
getPlaceholder()
Get placeholder.
at line 790
mixed
prepare($value)
Prepare for a field value before update or insert.
at line 798
$this
disableHorizontal()
No description
at line 808
array
getViewElementClasses()
No description
at line 830
array
getElementClass()
Get element class.
at line 842
$this
setElementClass(string|array $class)
Set form element class.
at line 856
$this
addElementClass($class)
Add the element class.
at line 872
$this
removeElementClass($class)
Remove element class.
at line 897
$this
resetElementClassName(string $className, string $resetClassName)
reset field className.
at line 909
string
getLabelClass()
No description
at line 919
Field
setLabelClass(array $labelClass)
No description
at line 931
array
variables()
Get the view variables of this field.
at line 956
string
getView()
Get view of this field.
at line 974
string
setView(string $view)
Set view of current field.
at line 981
string
getType()
No description
at line 994
$this
setDisplay(bool $display)
To set this field should render or not.
at line 1018
Factory|View|string
render()
Render this filed.
at line 1035
string
__toString()
No description
at line 1045
string
getRules()
Get field validation rules.
at line 1091
array|mixed|string
formatName(string $column)
Format the name of the field.
at line 1132
protected mixed
formatColumn(string $column = '')
Format the field column name.
at line 1150
protected string|array
formatId(string|array $column)
Format the field element id.
at line 1162
protected string
formatLabel(array $arguments = [])
Format the label value.
at line 1174
protected
formatValue()
Format value by passing custom formater.
at line 1187
protected
addRequiredAttribute(array $rules)
Add required
attribute to current field if has required rule,
except file and image fields.
at line 1197
protected
addRequiredAttributeFromRules()
If has required
rule, add required attribute to this field.
at line 1218
protected array
formatRules(array|string $rules)
Format validation rules.
at line 1233
protected array|Closure
mergeRules(string|array|Closure $input, string|array $original)
No description
at line 1256
protected void
removeRule(string $rule)
Remove a specific rule by keyword.
at line 1279
protected array
sanitizeInput(array $input, string $column)
Sanitize input data.
at line 1294
protected string
formatAttributes()
Format the field attributes.
at line 1310
protected mixed
getElementClassString()
Get element class string.
at line 1333
protected string|array
getElementClassSelector()
Get element class selector.
at line 1357
protected string
getGroupClass(bool $default = false)
Get element class.
at line 1369
Field
setGroupClass(string|array $class)
Set form group class.
at line 1388
protected Field
addVariables(array $variables = [])
Add variables to field view.
at line 1403
protected bool
shouldRender()
If this field should render.