Basic Usage
Attributes
The name attribute for the select element
Label text for the select field. Auto-generated from name if not provided
Options to display in the select. Can be:
- Array with key-value pairs:
['value' => 'Label'] - Eloquent query builder:
Category::query() - Empty array (use slot for custom options)
Placeholder text for empty option. Shows as first option with empty value
Enable multiple selection. Automatically adds
[] to name and includes sync fieldModel instance for value binding. Can be Eloquent model, array, or object
Default selected value when no model is bound
Mark field as required
Disable the select element
Show/hide the label element
Auto-generate placeholder from label if placeholder not provided
Display validation errors
Display JavaScript validation errors
Render in inline layout
Use floating label style
Field name to use for option labels when using Eloquent query (default: ‘name’)
Field name to use for option values when using Eloquent query (default: primary key)
Indicate this select represents a model relationship
Exclude the hidden sync field for multiple selects
Custom name for the sync field (default:
sync_{name})Enable tag creation. Includes old input values as options
CSS classes for inline label
CSS classes for inline input wrapper
CSS classes for form group wrapper
Examples
With Placeholder
Multiple Selection
Multiple selects automatically include a hidden sync field to handle empty submissions. Use
exclude-sync-field to disable this behavior.With Eloquent Query
name field for labels.
Custom Field Names
Model Binding
$article->status.
Using Enum Values
With Slot for Custom Options
The slot is only used when the
options attribute is empty.Custom Sync Field
Sync Field Behavior
Whenmultiple is true, a hidden input field is automatically included:
exclude-sync-fieldis truedisabledis truemultipleis false
Value Binding
The component handles various value types:- Eloquent Models: Extracts the primary key or
id-fieldvalue - Collections: Uses
pluck()withid-fieldfor multiple selects - Backed Enums: Automatically extracts the enum value
- Arrays: Directly uses the array values
- Old Input: Automatically populates from
old()input
Option Sources
Array Options
Query Builder
- Automatically uses
pluck($nameField, $idField) - Supports accessor attributes
- Works with translatable models (Javaabu Translatable)
CSS Classes
The select element includes:form-select- Bootstrap 5 select classis-invalid- Added when validation errors exist- Additional Select2 classes when
is-select2is true (used internally by Select2 component)