I am pretty sure the problem is that you didn’t instantiate the model with the proper scenario
$model= new Questions();
$model->setAttributes(array('classification_search'=>'foobar')); // won't work
$model= new Questions("search");
$model->setAttributes(array('classification_search'=>'foobar')); // should work
Thanks Haensel that seems to have worked. Although I’m not sure how or why.
I changed the admin action to instantiate a new Question model just as you advised and it works fine but what’s odd is that the only two fields that were causing the problems where ones that I had too define myself. The one that was straight from the model ‘question’ was working fine.
But when I instantiated like…
$model=new Questions("search");
… the two that weren’t working are now working. Can you explain the difference please so I might get a better understanding of how yii operates.
Well, by appending “on”=>“search” you specified that the attributes can only be set when the current scenario is “search” which wasn’t the case. If you look at the search() method in your modelclass (if you used gii to create the model) you would see that a new instance is created by passing “search” to the constructor telling the model what the current scenario is.