thedevdojo / voyager

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

Add or Edit Required Fields Mandatory * is not showing #5808

Open blpraveen opened 8 months ago

blpraveen commented 8 months ago

Laravel version

8

PHP version

7.4

Voyager version

1.4.3

Database

Mysql 8

Description

In admin Model required form fields should have astrick (*) Mark. Currently User as know information of which fields are mandatory

Steps to reproduce

In User Create fields dont have astrick (*)

Expected behavior

Should have astrick before Field Label

Screenshots

image

Additional context

No response

salmazz commented 7 months ago

what are u doing for this issue?

Emerica commented 7 months ago

Just use the required options in the bread, unless that's the actual bug here? No asterisk's are displayed, but validation should fail and then present a warning, a little late, sure. { "validation": { "rule": "required" } }

I wouldn't consider this a bug. There's no need to assume they are required fields. Probably, sure, but not required. You have the ability to overload the BREAD resources and specify a controller to control these aspects for the needs of your application.

Make a /resources/vendor/voyager/[model]/ folder , so /resources/vendor/voyager/users/
Copy the /vendor/tcg/voyager/resources/views/users/edit-add.blade.php to /resources/vendor/voyager/users/edit-add.blade.php

^ make your changes to that blade, maybe make a list of "required" options in your User model like fillable. Or dive into where the validations are stored. Then in your edited blade, as you loop through the model columns your can check if it's in the models required array and add your asterisk's and any other logic.

Then if you need more can extend the VoyagerBaseController, or make your own, and point your bread at that controller instead of the default.

blpraveen commented 5 months ago

Hi @Emerica Is it possible to use/override one edit-add.blade.php to all models?

Emerica commented 5 months ago

@blpraveen Just wakin' up, so the brainpan might not be top notch, but you could try sym-linking?

Emerica commented 5 months ago

Revisiting this hacky solution, you could also copy the VoyagerBaseController into your project and then change how it operates, point at a single blade instead of it being dynamic. With the dev cycle now being kinda dead you at least don't need to worry about it changing as much.

https://github.com/thedevdojo/voyager/blob/7866a2d287c72b2682322d84f691974eb68c9331/src/Http/Controllers/VoyagerBaseController.php#L320 https://github.com/thedevdojo/voyager/blob/7866a2d287c72b2682322d84f691974eb68c9331/src/Http/Controllers/VoyagerBaseController.php#L322