Hi guys,
I am developing an single module application that amongst others, can handle multiple users. I have created the required form with all the required fields and the action that handles the creation of the user. However, when I try to add a user, I get a message after a few seconds that this email has already been registered (the message come from the uniqueness of the email field). However, when I view the users table, I see that the user has been created and can login too. This hints that the action was called more than once.
Here is my create action:
public function createAction()
{
if ($this->request->isPost()) {
$user = new Users();
$user->assign(array(
'first_name' => $this->request->getPost('first_name', 'striptags'),
'last_name' => $this->request->getPost('last_name', 'striptags'),
'business_name' => $this->request->getPost('business_name', 'striptags'),
'business_type_id' => $this->request->getPost('business_type_id', 'int'),
'vat_no' => $this->request->getPost('vat_no', 'striptags'),
'doy_id' => $this->request->getPost('doy_id', 'int'),
'country_id' => $this->request->getPost('country_id', 'int'),
'address' =>$this->request->getPost('address', 'striptags'),
'phone1' => $this->request->getPost('phone1', 'striptags'),
'phone2' => $this->request->getPost('phone2', 'striptags'),
'user_url' => $this->request->getPost('user_url'),
'profiles_id' => $this->request->getPost('profiles_id', 'int'),
'email' => $this->request->getPost('email', 'email'),
'banned' => $this->request->getPost('banned'),
'suspended' => $this->request->getPost('suspended'),
'active' => $this->request->getPost('active')
));
if (!$user->save()) {
$this->flash->error($user->getMessages());
} else {
$this->flash->success("User was created successfully");
Tag::resetInput();
}
}
$this->view->form = new UsersForm(null);
$this->view->heading = "Create user";
$this->tag->setTitle("Create User");
}
Can anyone help me figure this out? As far as I can tell, the action is correct. The form is just a simple bootstrap form with a few fields and a submit button...