How can I add a url to the label of a checkbox

I have a form, and I need to add a link to the text of a checkbox field. But I don't know how to do it. With url() it doesn't work, it says it doesn't exist, I guess for checkbox it's something else. Can you help me? thank you
8 Replies
Dennis Koch
Dennis Koch11mo ago
I think I would use a hint() on the field to display a link.
astronomic
astronomic11mo ago
Yees, thank you so much!! Since with hint() I couldn't find a way to open the link in another tab, I had to use this: Checkbox::make('rgpd') ->accepted() ->label(new HtmlString('<a style="color: blue;" href="/storage/documents/rgpd/Gymclass - RGPD.pdf" target="_blank">Acepto la Normativa de Protección de Datos</a>')) ->required(), but now if I don't select the checkbox the error message appears with the html tag, how can I solve it? Is there a way to open in another tab with hint()
Dennis Koch
Dennis Koch11mo ago
The same should work with a hint? 🤔 There's also helperText
astronomic
astronomic11mo ago
Ok thanks, it works! But how can I prevent the automatic checkbox label from appearing?
Dennis Koch
Dennis Koch11mo ago
Not sure. It's a browser feature. You'd need a novalidate on the Form. Since you are using standalone form builder you should be able to add that
astronomic
astronomic11mo ago
I have tried using an empty label so it works but there is a huge space between the checkbox and its label I need to validate the checkbox, the form cannot be sent if the person has not selected it
Dennis Koch
Dennis Koch11mo ago
novalidate only affects client side valdiation
astronomic
astronomic11mo ago
I'm sorry but I didn't quite understand you. In the end I solved it with CSS: Checkbox::make('rgpd') ->accepted() ->label('') ->hint(new HtmlString('<a class="text-config" style="color: blue;" href="/storage/documents/rgpd/Gymclass - RGPD.pdf" target="_blank">Acepto la Normativa de Protección de Datos <span style="color:red;">*</span></a>')) ->required(), Thank you so much for all