Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

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

Open
blpraveen opened this issue Oct 20, 2023 · 5 comments
Open

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

blpraveen opened this issue Oct 20, 2023 · 5 comments

Comments

@blpraveen
Copy link

blpraveen commented Oct 20, 2023

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

@blpraveen blpraveen changed the title Add or Edit Required Feilds Mandatory * is not showing Add or Edit Required Fields Mandatory * is not showing Oct 20, 2023
@salmazz
Copy link

salmazz commented Nov 26, 2023

what are u doing for this issue?

@Emerica
Copy link
Contributor

Emerica commented Nov 26, 2023

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
Copy link
Author

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

@Emerica
Copy link
Contributor

Emerica commented Jan 25, 2024

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

@Emerica
Copy link
Contributor

Emerica commented Jan 26, 2024

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.

$view = 'voyager::bread.edit-add';

if (view()->exists("voyager::$slug.edit-add")) {

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants