Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Virtual Attributes In Model Won't Bind

$
0
0
Hi guys,

Whenever I add a virtual attribute field to my model like so:

class User extends CActiveRecord
{
	public $title;


I can't seem to bind the data in my update action in the controller:

public function actionUpdate($id)
	{
		$model = $this->loadModel($id);
		if(isset($_POST['User']))
		{
			$model->attributes = $_POST['User'];

 			if($model->save())
 				$this->redirect(array('view','id' => $model->userId));
		}

		$this->render('update',array(
			'model'=>$model,
		));
	}


Then when I go look at what's in $model->attributes i can't find my $model->title anywhere.
It's in the $_POST['User'], but for some reason it won't bind to my model.
Anyone got any thoughts on how to troubleshoot this?

Thx in advance!

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>