Symfony, forms and widgets tips

Howto get the user object in a form

Solution to get to user object in an sfForm object: use the 2nd $option parameter while creating the form object and retrieve it.

// In your actions.class.php
$this->form = new myForm(array(), array("currentUser" => $this->getUser()));

// In your form class

// ...
if (!is_object($this->getOption("currentUser")) || !($this->getOption("currentUser") instanceof sfUser))
throw new InvalidArgumentException("You must pass a user object as an option to this form!);