thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Add an option to provide a default value for the Media Picker formfield #5640

Closed christie-hill-za closed 2 years ago

christie-hill-za commented 2 years ago

Laravel version

9.0

PHP version

8.0.2

Voyager version

1.5.2

Description of problem

I would like to specify a default value for an instance of the media picker formfield in one of my models and there currently doesn't seem to be an option for it according to the documentation page.

Some other fields have this option available in their BREAD configuration.

Proposed solution

Add another customisation option to the BREAD settings for the Media Picker field that allows a default value to be specified. { "default": "path/to/default.jpg" }

Alternatives considered

Don't set the field to required in the database settings and allow NULL. I will try to work on a PR for this in my spare time.

Additional context

This setting does not seem to work with the Media Picker field.

Screenshot 2022-07-25 at 12-40-04 Edit BREAD for posts table

emptynick commented 2 years ago

Use a BREAD accessor (for add in your case) to provide a default value. I think putting a static path into the json options isn't really a good idea. With the accessor you are able to do some more dynamic things.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.