The select
field type stores a selection from a list of options.
// streams/users.json
"fields": {
"status": {
"type": "select",
"config": {
"options": {
"enabled": "Enabled",
"pending": "Pending",
"disabled": "Disabled"
},
"default": "pending"
}
}
}
Besides basic array and associated arrays, you may specify an invokable class:
{
"type": "select",
"config": {
"options": "\\App\\InvokableOptions"
}
}
Or, callable class and method:
{
"type": "select",
"config": {
"options": "\\App\\CustomOptions@handle"
}
}
The $type
can be injected in order aid in returning options:
// app/InvokableOptions.php
class InvokableOptions
{
public function __invoke($type)
{
return [
'foo' => 'Bar',
];
}
}
// app/CustomOptions.php
class CustomOptions
{
public function handle($type)
{
return [
'foo' => 'Bar',
];
}
}
{
"status": "enabled"
}
Basic value access displays the stored key value:
@verbatim// Basic access
{{ $entry->status }}@endverbatim
Select types also provide decorated values.
@verbatim// Decorated value
Status: {{ $entry->status()->value() }}@endverbatim
@todo Generate methods from @docs
@todo Generate config options from class::configuration
A blank TALL-stack Laravel project with Streams.
The fundamental features and utilities offered by the Streams platform.
A universal and extensible RESTful API for Streams.
Extensible, user-friendly, and performant control panel, components, and services.
Dev tooling for Laravel Streams.