How can I add an asterisk next to a required field when using ->rules(['required'])?

How can I add an asterisk next to a required field when using ->rules(['required'])? I tried using ->markAsRequired(), but that seems to only work as a modifier to ->required(). I am not using the ->required() method because I don't want browser validation; only Laravel validations. Here is my code:
TextInput::make('sample')
->rules(['required'])
->markAsRequired()
TextInput::make('sample')
->rules(['required'])
->markAsRequired()
See image for the output.
No description
2 Replies
dissto
dissto11mo ago
TextInput::make('sample')
->required() // adds frontend validation aka the asterisk
->rules(['required'])
->markAsRequired();
TextInput::make('sample')
->required() // adds frontend validation aka the asterisk
->rules(['required'])
->markAsRequired();
nvm i missed the part where you didnt want front end validation 🤣
// dirty way
TextInput::make('name')
->label(function () {
return new HtmlString(static::getModelLabel() . '<span class="text-danger-600 dark:text-danger-400 font-medium">*</span> Name');
}),
// dirty way
TextInput::make('name')
->label(function () {
return new HtmlString(static::getModelLabel() . '<span class="text-danger-600 dark:text-danger-400 font-medium">*</span> Name');
}),
prapok01
prapok0111mo ago
how to manage this
No description
Want results from more Discord servers?
Add your server