Select
The #[Select]
property type will render a dropdown select input in the field properties panel.
Very similar to the #[Checkboxes]
property type, but only allowing a single selection.
You can use an #[OptionGenerator]
attribute to dynamically populate the options for the select input.
You can use a #[ValueGenerator]
attribute to pre-select a default option when the field is first created.
use Solspace\Freeform\Attributes\Property\Input\Select;
// ...
#[Select(
label: 'Color Scheme',
instructions: 'Select the color scheme for this field.',
emptyOption: 'Select a color scheme...',
options: [
'light' => 'Light',
'dark' => 'Dark',
'system' => 'System Default',
],
)]
protected string $colorScheme = 'light';