Hi, all. I think i did not understand this embed form system, so i
need some help...
Pretty usual example is registration form.
I have two tables sf_guard_user and sf_guard_user_profile and two
forms.
This is usual forms with all necessary widgets and validators.
This is my sing up action:
public function executeIndex($request)
{
$singupForm = new SingupUserForm();
$userProfileForm = new SingupUserProfileForm();
$singupForm->embedForm('Profile', $userProfileForm);
$this->singupForm = $singupForm;
if ($request->isMethod('post'))
{
$singupData = $request->getParameter('singup');
$singupData['username'] = $singupData['email']; // don`t think
about it
$singupData['algorithm'] = 'sha1'; // and about it too ;)
$this->singupForm->bind($singupData);
if($this->singupForm->isValid()){
$newUserId = $this->singupForm->save();
$newUserProfileFrom = new SingupUserProfileForm();
$newUserProfileData = $singupData['Profile'];
$newUserProfileData['user_id'] = $newUserId->id;
$newUserProfileFrom->bind($newUserProfileData);
$newUserProfileFrom->save();
//$this->redirect('singup/thankyou');
}
}
this works fine and i got records in both tables, BUT if a cant just
do $this->singupForm->save(); and get all things done... i think i do
something wrong...
and this piece of code makes 4 queries to database!!! i don`t need
this at all;)
i can still use something like that (it works great):
$newUser = new sfGuardUser();
$newUser->email = '[EMAIL PROTECTED]';
$newUserProfile = new sfGuardUserProfile();
$newUserProfile->first_name = 'alex';
$newUser->setProfile($newUserProfile);
$newUser->save();
but i believe there is a better way for forms.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---