Bug with select->multiple(), other ->live() components and $get()?

Hi, I have this component added to the form:
protected static function getUsersFormComponent() : Components\Component
{
return Components\Select::make('users')
->label(__('Employees'))
->searchable()
->relationship('users', 'name')
->preload()
->exists(table: User::class, column: 'id')
->multiple();
}
protected static function getUsersFormComponent() : Components\Component
{
return Components\Select::make('users')
->label(__('Employees'))
->searchable()
->relationship('users', 'name')
->preload()
->exists(table: User::class, column: 'id')
->multiple();
}
And then I have various components with ->live() on them which uses $get() and $set() on the form. This all works fine with a regular Select, but when adding ->multiple() to the select the form breaks because $get('some_value') will return null. If I remove ->multiple() from the select again I get the values. This happens when you interact with the select, removing or adding users for instance. I'm wondering if anyone else has experienced this and if it might be a bug.
5 Replies
bjornbjorn
bjornbjornOP12mo ago
yes
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
LeandroFerreira
LeandroFerreira12mo ago
Does it work?
Select::make('users')
->multiple()
->preload()
->relationship('users', 'name')
->live(),
Placeholder::make('Users')
->content(fn (Get $get): string => implode(', ', $get('users') ?? []))
Select::make('users')
->multiple()
->preload()
->relationship('users', 'name')
->live(),
Placeholder::make('Users')
->content(fn (Get $get): string => implode(', ', $get('users') ?? []))
bjornbjorn
bjornbjornOP12mo ago
yes, that code works fine. The issue is that i clears the state of the other ->live() components .. or rather, doesn't clear them in the UI but if I do $get('some_state') after interacting with the users select that other state returns 'null'
LeandroFerreira
LeandroFerreira12mo ago
maybe you could share the whole code
Want results from more Discord servers?
Add your server