Closed amismailz closed 9 months ago
@amismailz
Hi, following code works in my environment.
protected function form()
{
$form = new Form(new User());
$form->text('name', __('Name'));
$form->email('email', __('Email'));
$form->radio('sex1', 'Sex(number)')->options([0=>'male', 1=>'female', 2=>'other'])->default(0);
$form->radio('sex2', 'Sex(string)')->options(['male'=>'male', 'female'=>'female', 'other'=>'other'])->default('male');
$form->datetime('email_verified_at', __('Email verified at'))->default(date('Y-m-d H:i:s'));
$form->password('password', __('Password'));
$form->text('remember_token', __('Remember token'));
return $form;
}
Snapshot of DB
Snapshot of editing user id=1
Snapshot of editing user id=3
Is it possible to check the actual DB values?
@fits-fujiura-st What is the field data type you use? did you use enum?
@amismailz
I used int for number and varchar for string.
@fits-fujiura-st I just got the cause of this issue, this was because I make some getter functions (attribute accessors) like this:
public function getGenderAttribute($value)
{
return __(ucfirst($value));
}
I'll try another way to handle this.
Thank you so much, I really appreciate your great support :+1:
Description:
While using dropdowns / radio buttons in the update form, saved values are not being selected if options have string keys but works with integer ones.
Steps To Reproduce:
Not working (No inputs are selected)
Works (Male is selected)