Take the 2-minute tour ×

I'm using Symfony 1.2 in a standard Propel form class.

public function configure()
'graduate_job_title' => new sfWidgetFormInput( array(), array( 'maxlength' => 80, 'size' => 30, 'value' => '' ) )

However, I want the value of this field to come from the user information, which I'd normally access using $this->getUser()->getAttribute( '...' ). However, this doesn't seem to work in the form.

What should I be using?

share|improve this question

3 Answers 3

up vote 5 down vote accepted

Does that work?


// Edit : See cirpo's recommandation on the use of sfContext instead.

share|improve this answer
Works, thank you! –  James Inman Mar 13 '09 at 0:45
Thank you, it works –  Nordes May 27 '10 at 16:03

It's a very bad idea to rely on the sfContext instance. It's better to pass what you need during sfForm initialization in the options array parameter.


__contruct method

for example in your action:

$form = new myForm(null, 
                   array('attributeFoo' => 

and then retrieve the value inside the form class:



share|improve this answer
What if you are using a plugin like sfDoctrineGuard which autogenerates the forms? I am not directly creating the forms in my own classes. –  codecowboy Apr 28 '11 at 15:15
It was what I was looking for. Thanks! In my case it work with Symfony 1.4 –  Tomasz Kuter May 15 at 17:07

If someone need the same in admin (backend) here is a solution: http://blog.nevalon.de/en/wie-nutze-ich-die-rechteverwaltung-in-symfony-admin-generator-formularen-20100729

share|improve this answer

Your Answer


