Create select option form without relationship

Trying to use the createOptionForm so that it works without a relationship.

This almost works apart from the select value/select option, is not updated even though the state is updated correctly.

Forms\Components\Select::make('group')
    ->native()
    ->required()
    ->options(function ($state): array {
        $options = [];// fetch unique groups from DB
        if ($state && ! isset($options[$state])) {
            $options[$state] = $state;
        }
        return $options;
    })
    ->createOptionForm(fn (): array => [
        Forms\Components\TextInput::make('group')
    ])
    ->createOptionUsing(fn (array $data) => $data['group']),
Was this page helpful?