Problem with controller, view

Hi,

I have this view:





<div class="form">


	<?php echo CHtml::beginForm(); ?>

		

		<?php echo CHtml::errorSummary(array($view->company, $view->user)); ?>

		

		<fieldset>

			

			<legend>Company details</legend>

			<p>Enter your company details here.</p>

					

			<label>Company name</label><br />

    		<?php echo CHtml::textField($view->company, "name") ?><br />


			<label>Company contact number</label><br />

    		<?php echo CHtml::textField($view->company, "contact_number") ?>


		</fieldset>

		

		<fieldset>

			

			<legend>User details</legend>

			<p>Enter your user details here.</p>


			<label>Email</label><br />

	    	<?php echo CHtml::textField($view->user, "email") ?><br />

	

			<label>Confirm your email</label><br />

	    	<?php echo CHtml::textField($view->user, "email_confirmation") ?><br />

	

			<label>Firstname</label><br />

	    	<?php echo CHtml::textField($view->user, "first_name") ?><br />

	

			<label>Lastname</label><br />

	    	<?php echo CHtml::textField($view->user, "last_name") ?><br />

	

			<label>Password</label><br />

	    	<?php echo CHtml::passwordField($view->user, "password") ?><br />

	

			<label>Confirm your password</label><br />

	    	<?php echo CHtml::passwordField($view->user, "password_confirmation") ?><br /><br />

	

			<?php echo CHtml::submitButton("Sign up your new account"); ?>

	

		</fieldset>

    	

    <?php echo CHtml::endForm(); ?>

		

</div>




I have this controller action:





public function actionSignUp() {

			

			$company = new Company;

			$user = new User;

			

			if(isset($_POST["Company"], $_POST["User"])) {

				

				$company->attributes = $_POST["Company"];

				$user->attributes = $_POST["User"];

				

				if($company->validate() && $user->validate()) {

					

					$company->save();

					$user->fk_id_with_company_id = $company->id;

					$user->save();

					$this->redirect(array("site/index"));

					

				}

				

			}

			

			$view->company = $company;

			$view->user = $user;

			$this->render("SignUp", array("view" => $view));

			

		}

		

	}




I am getting this error: -

"Object of class Company could not be converted to string"

Can anybody see what the problem is?

I have resolved this issue now, it was because I did not put "active" in front of the fields. This was because I was using "activewidget" rather than C:Form.

This stuff is a bit confusing.

In general, Chtml helpers works like that:

Chtml::ACTIVEtexField => wants model and attribute;

CHtml::textField => wants label and value

The strange stuff is that CForm::textField is a wrapper for CHtml::activeTextField. That has a meaning, because CForm is not supposed to work with label and value, but is a bit couter-intuitive when you have to pass from CHtml to CForm.