1

So I've searched, googled, asked and even consulted the stars, but I haven't been able to find a solution to this specific problem.

When overriding an FOSUserBundle form,(specifically the Change Password form, but generally any other FOSUserBundle form), is there a way to set part of the field label to be a hyperlink?

Does the question make sense? I could elaborate if it doesn't.

The goal

I would like to have resultant HTML to look like this:

<div>
    <label for="fos_user_resetting_form_has_acceptedtos">I agree to the <a href='/tos/'>Terms Of Service</a>.</label>
    <input id="fos_user_resetting_form_has_acceptedtos" type="checkbox" value="1" name="fos_user_resetting_form[has_acceptedtos]">
</div>

What I've tried. . .

I have added the has_acceptedtos field to the User.php Entity and hooked into the controller, as per the instructions. And I have customized the field labels successfully.

Unfortunately, the following syntax, unsurprisingly, doesn't work either:

# app/Resources/FOSUserBundle/translations/FOSUserBundle.en.yml
# ...
# Password change
change_password:
    submit: Change password
    has_acceptedtos: I agree to the <a href='/tos'>Terms Of Service</a>.
...

I have even attempted to override the template, in an attempt to artificially create a label that would appear in the vicinity of the checkbox via css. Didn't work out too well.

Other than re-writing the entire FOSUserBundle to generate my own forms, can this even be accomplished?

Thanks in advance for any suggestions!

Community
  • 1
  • 1
Sanuglia
  • 45
  • 8

1 Answers1

0

You'll have to use a combination of custom form theming and the Twig "raw" method to accomplish this.

Here's an answer that deals with a quite similar issue.

Community
  • 1
  • 1
Peter
  • 808
  • 7
  • 15