On Tuesday 06 July 2010 01:08:12 Jackson Gabbard wrote:
> I'm working on a system that enables users to contribute bits of
> content (varchar 255) into a pool that gets moved into a different
> system later. I've got Symfony 1.4 up and running with the sgGuardAuth
> plugin in place and working properly. Also, my MVC layers are all in
> order, displaying forms and behaving expectably. What I'm not seeing
> is a clear mechanism for inserting an authenticated user's ID into the
> form after the user submits their content but before saving the user's
> submission so that I know what user has submitted what information.
> 
> My model includes an sf_guard_user_id field that I want to populate
> with the ID of the authenticated user, but there doesn't seem to be a
> clean way to do this. I attempted overwriting the request with the
> field I want in the executeCreate method but I got an unexpected field
> error, which makes sense. So, I tried setting the field in the model
> for the specific object, but the problem is that the object is not
> user context aware. So, the only place that seems to make sense is the
> processForm method after the form validity check, but the form object
> doesn't seem to have a straightforward mechanism for setting specific
> field values. Am I missing something?
> 
> Any help would be much appreciated,
> 
> Jackson

Why not store the users ID into a session variable on login:

$this->getUser()->setAttribute('user_id', $user_id);

and then set the user_id field you want stored in the model entry after a form 
has been submitted using:

$this->getUser()->getAttribute('user_id');

Regards

Gareth McCumskey

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to