-
-
Notifications
You must be signed in to change notification settings - Fork 108
Automatically add a red star to the label when a field is marked as required #369
Conversation
As requested in the Splade Discord so we are able to do:
```php
->label(__('Title <span class="text-red-500">*</span>'))
```
|
Could be a nice idea to automatically add a red star to the label when a field is marked as required, I'm working on this. |
|
I achieved it like this: in form.label.blade.php
|
|
@AliasSuperman just added this approach, had to add |
|
I'm not a fan of the default HTML5 validation capabilities. I would suggest adding Input::make('hiddenInput2')
->htmlLabel('Title <span class="text-red-500">*</span>');
// which will be a shortcut to:
Input::make('hiddenInput2')
->label(new HtmlString('Title <span class="text-red-500">*</span>')); |
|
Good idea! |
|
@J87NL Can this PR be closed now that we have |
|
Preferably not, this PR adds the red asterisks automatically to all FormBuilder Splade-fields that have a required rule, so without the need of adding extra htmlLabels to all fields where you want one. I've added a config variable to enable/disable the asterisks. |
|
Must admit it's quite nice! One more question: what the reason behind using |
|
Just 'required' would make it HTML5-validation which would prevent the form from being able to submit, and therefore you won't see the formrequest validation. |
As requested in the Splade Discord so we are able to do: