I really got a weird problem where a user register symfony save 2 time in the sf_guard_user table (one empty) and link the profile to the empty row.
I do not hit submit form 2 time, and the action is only executed once. The debug bar tell me that it really save 2 time in the DB, once with empty data.
Really frustrating
Schema:
BambinbazarUsers:
actAs:
Geographical: ~
columns:
sf_guard_user_id: integer
company: { type: string(255) }
url: { type: string(255) }
usertype: { type: string(255) }
address: { type: string(255) }
city: { type: string(255) }
facebookid:{ type: string(255)}
state: { type: string(255) }
zipcode: { type: string(255) }
Country: { type: string(255) }
telephone: { type: string(255) }
relations:
BambinbazarArticles:
class: BambinbazarArticles
local: sf_guard_user_id
foreign: userid
type: many
foreignType: one
sfGuardUser:
onDelete: CASCADE
local: sf_guard_user_id
foreign: id
foreignAlias: BambinbazarUsers
foreignType: one
Action (nor changed) :
if ($this->getUser()->isAuthenticated())
{
$this->getUser()->setFlash('notice', 'You are already registered and signed in!');
$this->redirect('@homepage');
}
$this->form = new sfGuardRegisterForm();
if ($request->isMethod('post'))
{
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid())
{
$user = $this->form->save();
$this->getUser()->signIn($user);
$this->redirect('@view_my_profile');
}
}
form configure:
public function configure()
{
$profileForm = new BambinbazarUsersForm($this->object->BambinbazarUsers);
unset($profileForm['id'], $profileForm['sf_guard_user_id']);
$this->embedForm('Profile', $profileForm);
}