How to selected value for edit form

Like title said, I only managed to fill default value for TextInput.
4 Replies
Dennis Koch
Dennis Koch2y ago
Did you read the form builder section?
Cyrillus Dodi
Cyrillus DodiOP2y ago
yes I did, I tried with TextInput and it works, but not with Select component here is my code
public $organization;


public function mount(Organization $organization)
{
$this->organization = $organization;

$this->form->fill([
'organizationId' => $organization->id,
]);
}

protected function getFormSchema(): array
{
return [
Forms\Components\Select::make('organizationId')
->options(Organization::all()->pluck('name', 'id'))
->searchable(),
}
public $organization;


public function mount(Organization $organization)
{
$this->organization = $organization;

$this->form->fill([
'organizationId' => $organization->id,
]);
}

protected function getFormSchema(): array
{
return [
Forms\Components\Select::make('organizationId')
->options(Organization::all()->pluck('name', 'id'))
->searchable(),
}
toeknee
toeknee2y ago
public $organization;


public function mount(Organization $organization)
{
$this->organization = $organization;

$this->form->fill([
'organizationId' => [$organization->id],
]);
}

protected function getFormSchema(): array
{
return [
Forms\Components\Select::make('organizationId')
->options(fn() => Organization::all()->pluck('name', 'id'))
->searchable(),
}
public $organization;


public function mount(Organization $organization)
{
$this->organization = $organization;

$this->form->fill([
'organizationId' => [$organization->id],
]);
}

protected function getFormSchema(): array
{
return [
Forms\Components\Select::make('organizationId')
->options(fn() => Organization::all()->pluck('name', 'id'))
->searchable(),
}
Cyrillus Dodi
Cyrillus DodiOP2y ago
okay solved thanks
Want results from more Discord servers?
Add your server