laravellaravel-nova

Laravel Nova: Default Select Option From BelongsTo Field


I need to show selected country in the Belongs To Fields is there any method in which i can pass the value and it would be selected by default.


Solution

  • 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.