How to selected value for edit form

Like title said, I only managed to fill default value for TextInput.
4 Replies
Dennis Koch
Dennis Koch15mo ago
Did you read the form builder section?
Dodi Yulian
Dodi Yulian15mo 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
toeknee15mo 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(),
}
Dodi Yulian
Dodi Yulian15mo ago
okay solved thanks
Want results from more Discord servers?
Add your server
More Posts