Question about controller create by CRUD

I’m a newbie at using frameworks and i have a question.

What does “new User(‘search’);” do? I don’t understand the use of the ‘search’ argument.




	/**

	 * Manages all models.

	 */

	public function actionAdmin()

	{

		$model=new User('search');

		if(isset($_GET['User']))

			$model->attributes=$_GET['User'];


		$this->render('admin',array(

			'model'=>$model,

		));

	}



Thanks in advance.

It initializes the ‘scenario’ property to ‘search’ instead of the default ‘insert’. See also:

http://www.yiiframework.com/doc/api/CActiveRecord#__construct-detail

I’m not sure about the reason, but the effect would be that all the searchable attributes can be massively assigned in the statement




$model->attributes=$_GET['User'];



/Tommy

Thanks for the explanation but im having a hard time understanding what scenarios are.

I have read the documentation “Creating a Model” and search in google about it and i still don’t get it.

seems i jumped one line in my reading about scenarios ;D

so…




$model=new LoginForm;

$model->scenario='login';

if(isset($_POST['LoginForm']))

    $model->attributes=$_POST['LoginForm'];



so, to define a scenario is just like that? Seems easy. :lol:

Sorry again for the dumb questions…i’m new to the framework field (ANY FRAMEWORK ;D )