Reputation: 128
I've been struggling with creating a simple form that will later store data in the database, using Yii framework and none of the tutorials I have been following have been explanatory enough. The idea is that I am editing an existing Yii project and I need to add user registration functionality to the following project. So Gii is out of the option.
To my understanding I have created:
What is the general idea that I should follow in order to create a form in the view, and add data from that form on the database?
On the controller so far I have:
class UserController extends LSYii_Controller {
public function actionIndex() { }}
The model:
public static function insertUser($new_user, $new_pass,$new_full_name,$parent_user,$new_email)
{
$oUser = new self;
$oUser->users_name = $new_user;
$oUser->password = hash('sha256', $new_pass);
$oUser->full_name = $new_full_name;
$oUser->parent_id = $parent_user;
$oUser->lang = 'auto';
$oUser->email = $new_email;
if ($oUser->save())
{
return $oUser->uid;
}
else{
return false;
}
}
and on the view I have nothing since I am not sure on how to proceed. Any help will be greatly appreciated.
Upvotes: 0
Views: 3685
Reputation: 10943
One of the nice things about Yii is it's plugin architecture. There is a user registration and management module that will do all of this for you. It's free and available from:
Features:
You can edit the User class to add other fields or store those additional fields in another table if you didn't want to mess with the yii-user code/configuration.
Upvotes: 1