Reputation: 1001
following this link I am trying to create a register form and connect the form to tables "user" and "profile". In my controller I have copied the same code as follows:
public function actionRegistration()
{
$form = new CForm('application.views.user.registerForm');
$form['user']->model = new Users;
$form['profile']->model = new Profile;
if($form->submitted('register') && $form->validate())
{
$user = $form['user']->model;
$profile = $form['profile']->model;
if($user->save(false))
{
$profile->userID = $user->id;
$profile->save(false);
$this->redirect(array('/user/login'));
}
}
var_dump($form->submitted('register'));
$this->render('registration', array('form'=>$form));
}
I actually don't know what is $form->submitted('register') for and why it returns false!
Can anyone explain me what is that and what is 'register' value which is passed to the submitted function!? Also why it should return false while posting the form?
Upvotes: 1
Views: 185
Reputation: 11
the traditional way to get form data is
$model = new User;
if(isset($_POST["register"])){ //get the form data
...
$model->attributes=$_POST["register"]; //set model's attributes
...
}
for more examples you can go: http://www.yiiframework.com/doc/blog/1.1/en/comment.create
Upvotes: 1