Null option for Select Field

->options([
null => 'Standard',
14 => 'Every 2 Weeks',
30 => 'Every 30 Days',
60 => 'Every 60 Days',
90 => 'Every 90 Days',
'Never' => 'Never',
])
->options([
null => 'Standard',
14 => 'Every 2 Weeks',
30 => 'Every 30 Days',
60 => 'Every 60 Days',
90 => 'Every 90 Days',
'Never' => 'Never',
])
Works fine for saving, but Standard is not preselected on Edit if the value equals null. Suggestions for solving this?
6 Replies
Somebody
Somebody2y ago
null as array key is converted to empty string in php unfortunately maybe use ->placeholder('Standard')
Dan Harrin
Dan Harrin2y ago
exactly right no need for a null option at all
Mark Chaney
Mark ChaneyOP2y ago
A null option is needed to set it to null though too
Dan Harrin
Dan Harrin2y ago
why the placeholder option sets it to null
Mark Chaney
Mark ChaneyOP2y ago
Figured the placeholder did nothing. Okie dokie. Thanks!
dpetersson
dpetersson16mo ago
is the placeholder intended to set the option to null when ->relationship() is used for the options? for a record that has already been saved, selecting the placeholder doesn't appear to provide null, it just provides the last saved value.
Want results from more Discord servers?
Add your server