Problem with createOptionUsing in Single Select

I have a select that can be single or multiple.
I also want to add an option to the select.
The options arent directly related to a table.

Select::make('metadata_value')
->reactive()
->options(fn (callable $get) => $get('metadata_value_options') ?? [])
->multiple(fn (callable $get) => $get('metadata_value_multiple') ?? false)
->label('Value')
->required(true)
->createOptionForm([
    TextInput::make('metadata')
        ->required()
])
->createOptionUsing(function (array $data, Get $get, Set $set) {
    if ($get('metadata_value_multiple') === false) {
        $options = $get('metadata_value_options');
        $set('metadata_value_options', [
            ...$options,
            ...[
                $data['metadata'] => $data['metadata']
            ]
        ]);

        $set('metadata_value', $data['metadata']);
    }

    return $data['metadata'];
})
->columnSpan(6),  


This works perfectly with multiple select, im really confused why it is not working with just single select.
After adding the new option, it wont show on the options.
But I checked in livewire and its there same with the value (See Pic).
Its really hopeless now...
Im working on it for hours, d@#$% !t.
I hope someone can help or explain what im missing.

Note:
Im using mutateFormDataBeforeSave to process it for saving and mutateFormDataBeforeFill for showing it.
image.png
Was this page helpful?