putting asterisk (*) on the left side.
In a required field, What's the easiest way to put the asterisk on the left side instead of the right side?
19 Replies
CSS?
This one worked for me.
But doesn't mean it's the correct way. Dynamic forms that has hide/show function don't work by using this.
I don't get why you are using it personally?
Yeah, your script is executed on the inial page load but not if the form gets rerendered for any reason. I agree with toeknee, CSS would likely be a simpler solution. You can move the asterisk for a single field or all fields at once.
I’m not sure this would be any easier with css. What is the use case? Do rtl languages typically have the asterisk on the opposite side?
Ok, looking at the code you should be able to target ‘. filament-forms-field-wrapper-label’ and reverse the flex direction.
my client wants the asterisk on the left side.
But why... globally? Or jsut this one you have to remember as the programmer you have to guide clients sometimes unless there is logic.
globally. they mentioned that doing an asterisk at the left side is more color-friendly.
Just googled it too. https://www.nngroup.com/articles/required-fields/#:~:text=Should%20the%20asterisk%20precede%20or,most%20character%20of%20the%20label
Nielsen Norman Group
Marking Required Fields in Forms
Using an asterisk to mark required fields is an easy way to improve the usability of your forms. Only marking optional fields makes it difficult for people to fill out the form.
->label
could do the trick too. but the form has already a lot of fields.your solution works but it's awkward if the label is too long.
Ohh. this one works too!
Have you tried
inline-flex
? This could give you a slightly better result with the long labels.The label is already inline-flex that’s why I suggested just reversing it.
The label is but it has only one
span
as a child 😔Good shout, I just went with some old basic code hehe
One downside that you might bring up with the clients is that by putting the asterisk first the labels will now be unaligned if you have a mix of required and not required fields. That would drive my OCD crazy! 😂
Also, the article you referenced says “it’s unlikely to make a practical difference”, so you could point out that to them too.
Also what do you mean by “color-friendly”
But ultimately, if this is something they demand, as you said,
->label()
might be the best way.We're diving deep into labels on this thread, I love it 🤓