Páginas · Laravilt
Concerns
Reusable traits for labels, visibility, state, layout and closure evaluation.
The Laravilt\Support\Concerns traits are used by Component and by most form fields, table columns and schema components. Almost every setter also accepts a Closure, which is evaluated with dependency injection.
| Trait | Methods |
|---|---|
CanBeDisabled | disabled(bool|Closure $condition = true), isDisabled(), isEnabled() |
CanBeReadonly | readonly(bool|Closure $condition = true), isReadonly() |
CanBeRequired | required(bool|Closure $condition = true), isRequired() |
HasLabel | label(string|Closure $label), getLabel() (generated from the name if not set) |
HasPlaceholder | placeholder(string|Closure|null $placeholder), getPlaceholder() |
HasHelperText | helperText(string|Closure $text), hint(string|Closure $text), getHelperText() |
HasVisibility | hidden(bool|Closure $condition = true), visible(bool|Closure $condition = true), isHidden(), isVisible() |
HasColumnSpan | columnSpan(int|string|array|Closure $span), columnStart(...), columnSpanFull(), getColumnSpan(), getColumnStart() |
HasId | id(string|Closure|null $id), getId() |
InteractsWithState | state(mixed $state), default(mixed $state), getState(), hasState() |
EvaluatesClosures | evaluationContext(array $data = [], mixed $record = null, ?string $operation = null), operation(?string), getOperation(), getEvaluationRecord() |
Examples
php
EvaluatesClosures
When a closure is evaluated, its parameters are injected by name or type. Available values include:
Get $getandSet $set: read and write other fields' state (see Utilities)$data: the full evaluation data array$record: the current Eloquent record, if any$operation:create,editorview$state: the component's current state
php