views:

30

answers:

1

How do you insert a link_to into the 'invalid' message of a regular Symfony form? My form extends the sfGuardUserForm:

class SignupForm extends sfGuardUserForm
{
  public function configure()
  {

    ...

    new sfValidatorPropelUnique(array('model' => 'sfGuardUserProfile', 'column' => array('email')), array('invalid' => 'This email address is already in use. Use the forgot password function if you lost your password.'))

    ...

  }
}

I would like to link the text 'forgot password' to the @forgot_password route from the applications routing.yml. How would this be done?

Thanks in advance!

A: 

You can use the link_to() function to achieve this. You will have to load the UrlHelper first. This can be done before declaring your form class, like this:

sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
greg0ire
I had to also load the Tag helper before being able to use link_to() in the validator message. sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url', 'Tag'));Thanks for the help.
cvaldemar