Begintransaction() Not Worked

Hi all! help me pls fix mi code…

After submitting the form, it passes the validation, but does not fire the save method defined in the model SignUp

public function actionSignUp()


        $model = new SignUpForm();

        $userData = Yii::app()->request->getPost('UserExt');

        $companyData = Yii::app()->request->getPost('CompanyExt');



        if ($userData && $companyData) {

            $model->attributes = Yii::app()->request->getPost('SignUpForm');

            $model->user->attributes = $userData;

            $model->company->attributes = $companyData;

            if ($model->validate() && $model->save()) {


            } else {

                Yii::app()->user->setFlash('error', 'Invalid input data');






class SignUpForm extends CFormModel {

	public $company;

	public $user;

	public $password;

	public $password_repeat;

	public function init() {

		$this->company = new CompanyExt();

		$this->user    = new UserExt();


	public function rules() {

		return array(

			array('password, password_repeat', 'required'),

			array('password', 'compare'),



	public function save() {

		$transaction = Yii::app()->db->beginTransaction();

        echo " transation " . var_dump($transaction);

		try {

			if($this->company->save()) {

				$this->user->company_id = $this->company->id;

				if($this->user->save()) {


					return true;



		} catch(CException $e) {



		$this->addErrors(array_merge($this->user->errors, $this->company->errors));

		return false;


    public function onAfterValidate($event) {

        $this->user->password = $this->password;

        $this->user->encrypted_password = crypt($this->password);



After post i see "Invalid input data"…

The calling of $model->save() in your controller will always return FALSE as you mentioned at function save() in your model. That’s way you always get “Invalid input data”.

You should move the business logic out from your model by moving the content of function save() in SignUpForm to function actionSignUp in your controller.