I am using Symfony 1.4 and Doctrine 1.2 and sfDoctrineGuardPlugin. I have a article create page. On my article table, i have profile_id field for saving which user (author) wrote it.
My problem is, when a user write an article and click to save, even if i can get profile_id from user, i cant set profile_id automatically.
In my articleForm class, i can set default value for select box, but user can change it. If i try to make it read only, profile_id cannot be saved on db.
Here is my configure function from articleForm class:
// getting user_id $user = sfContext::getInstance()->getUser(); $user_id = $user->getGuardUser()->getId(); // converting for profile table $converter = Doctrine_Query::create() ->select('*') ->from('profile') ->where('sf_guard_user_id = ?', $user_id); // fetching $result = $converter->fetchArray(); $this->widgetSchema->setDefault('profile_id', $result['id']);
To make it read only, i used:
But as i said before, this way, profile_id cannot saved on db. Without second part of code, current id came as default but users can change it.
How can solve it? Any idea? Thanks a lot...