-
-
Notifications
You must be signed in to change notification settings - Fork 86
Select
tanthammar edited this page Apr 8, 2021
·
8 revisions
Extends BaseField
- Display a message when no item is selected.
- A list or flat key => value based Array, Collection or Closure.
@param array|\Closure|\Illuminate\Support\Collection $options
- OBSERVE: if you use a callable, it will be executed on EVERY re-render of the component! Maybe you should consider setting the $options in mount() instead?
- You can use a component method that returns an array; ->options($this->someMethod())
public function fields()
{
return [
$this->select(),
$this->selectAssociative(),
];
}
//using labels = key
public function select()
{
$options = ['Wifi', 'Bluetooth', 'Ethernet'];
return Select::make('Select')
->options($options)
->placeholder('Please select an option')
->rules(['nullable', Rule::in($options)]);
}
//using associative array
public function selectAssociative()
{
$options = ['Wifi' => 'wf', 'Bluetooth' => 'bl', 'Ethernet' => 'eth'];
return Select::make('Select')
->options($options)
->default('wf')
->placeholder('Please select an option')
->rules(['nullable', Rule::in(array_values($options))]);
}
<x-tall-select :field="$field" />
Extend Blade component (or override in config file)
Tanthammar\TallForms\Components\Select::class
//Select placeholders and help, applied as trans(...) or @lang(...)
'select-placeholder' => 'global.select_placeholder', //'Please select an option...'
- Installation
- Requirements
- v5 Upgrade Guide
- v6 Upgrade Guide
- v7 Upgrade Guide
- Support
- Quickstart
- Manual installation
- Optional
- Form component
- Field
- Field types
- Example Form
- Blade Components
- Notifications