How to add asterisk to every required field label?

Member | 21

Hello everybody!

$form->addText('foo', 'My foo field')

How can I have the “My foo field” appear as “My foo field*”?

…No, I don't want to add the asterisk by hand in the label. I want to add it programmatically in my renderer to every field that is required, but I can't manage to make it work :(

Thx for your help!

Last edited by bernhard (2022-03-10 18:04)

David Grudl
Nette Core | 7734

It depends on what HTML code you generate, but it goes something like this:

.required th label:after { content: '\a0*'; }
Rick Strafy
Nette Blogger | 36

Hi, if you have your own renderer, look how to add that class at…Renderer.php#L84

And then you can do it with css .required label:after { content: “*”; }