Populating edit form


I have this controller action for editing a company record: -

public function actionEditCompany() {


			$company = new Company;

			$company->id = Yii::app()->user->record->company->id;


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


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


				if($company->validate()) {







			} else {






			$view->company = $company;

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



And I have this view code: -

<div class="form">

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


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




			<legend>Company details</legend>

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


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

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

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

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

			<?php echo CHtml::submitButton("Edit the company details"); ?>



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



Could someone tell me why it is not populating the form?

Problem solved answer …

$company = $company->findByPK(Yii::app()->user->record->company->id);

Needed to say "$company =" rather than just "$company->findByPK(Yii::app()->user->record->company->id)"