Laravel Nova: Default Select Option From BelongsTo Field
From this issue on Github, I tried the following in one of my BelongsTo
relationship,
BelongsTo::make('countries')
->withMeta([
'belongsToId' => 1 // default value for the select
]);
.. and it worked perfectly.
You want to make sure that the value will be set correctly when editing so use the following code:
BelongsTo::make('countries')
->withMeta([
'belongsToId' => $this->countries_id ?? 1 // default value for the select
]);