3

I am trying to set a default value for a referenced field (relationship) in Laravel Voyager.

I have added a BelongsTo Relationship to a Voyager BREAD model referencing a field from another model. I have then added a default to the field Optional Details in my model.

{
    "default": "1"
}

I was expecting the drop down select in BREAD to start off with the default value, but the select starts with a 'none' option. Basically my default option has been ignored by Voyager.

GiulioG
  • 369
  • 4
  • 15
  • https://medium.com/@codebyjeff/laravel-5-5-optional-class-withdefault-and-attribute-defaults-a2e901dbad62 maybe this could help – Ahmed Aboud Apr 26 '19 at 08:44
  • Thank you for your help, but it looks like the article is not Voyager related. The problem is that I can easily force a default value at the application/model level, but that's not the solution I am looking for. I need to know if it's possible to do it using BREAD – GiulioG Apr 26 '19 at 08:52
  • https://github.com/the-control-group/voyager/blob/1.2/resources/views/formfields/relationship.blade.php#L36 i think it only show the none option if its not required if you make it required and gave a default value maybe your option will be listed first – Ahmed Aboud Apr 26 '19 at 09:19

0 Answers0