Closed mstfkhazaal closed 4 months ago
Im not sure that you can do that in createOptionUsing
can you confirm that works in a normal select field?
yes is normally worked i do this way and it work but not professional way
Hidden::make('zone_hide'),
SelectTree::make('zone')
->relationship(
relationship: 'parent',
titleAttribute: 'name',
parentAttribute: 'parent_id',
)
->live()
->createOptionForm([
TextInput::make('name')
->required()
->maxLength(255),
])
->createOptionUsing(function ($data, $set) {
$zone = Zone::create($data);
$set('item_hide', $zone->id);
})
->afterStateUpdated(function (Set $set, ?string $state, ?string $old, $get) {
if ($get('zone_hide') != null) {
$set('zone', $get('zone_hide'));
$set('zone_hide', null);
}
})
->expandSelected()
->searchable()
->enableBranchNode()
->withCount()
->required(),
Im pretty sure it should be done in the afterStateUpdated
and not in the createOptionUsing
.
@mstfkhazaal Did you figure it out?
What happened?
I want to change select after create new item
How to reproduce the bug
Example:
Package Version
3.1.41
PHP Version
8.2.0
Laravel Version
11
Which operating systems does with happen with?
No response
Notes
No response