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.
Asked
Active
Viewed 7,822 times
6
-
Please, show what you tried so far and share some code. – Camilo Jan 14 '19 at 13:33
-
there is only belongsTo Field BelongsTo::make('countries') i need to select default value – Nabeel Qadri Jan 14 '19 at 13:37
2 Answers
5
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
]);

ykay says Reinstate Monica
- 4,634
- 4
- 32
- 42