Rui Gonçalves
Rui Gonçalves

Reputation: 2433

Symfony form get user id

In order to filter the available options on one section of my web application, I would like to get the user object at the form object. I found some information about possible ways to do that (using sfContext, for instance) but some users discouraged this approach.

What is a possible manner to achieve my purpose?

Upvotes: 0

Views: 1690

Answers (1)

DuoSRX
DuoSRX

Reputation: 4189

The best way is to add some logic to BaseForm so you can use self::getValidUser(); without ever using sfContext, which is indeed generally not recommended.

Check this awesome blog post for more infos : http://prendreuncafe.com/blog/post/2010/02/17/User-Dependant-Forms-with-Symfony

Upvotes: 4

Related Questions