according my controller, my debugging "debug2" is display. but #model->save is not working. How should I do? or Do I need to do as MySQL stored producer?
to check one of the product is live or expired when the user view their products list. So, I’ve to validate before displaying the product list.
@riemann, thank you for your point. I got bool(false) msg. And I create $model->scenario at create and update action. And I set those $model->scenario at mode’s rule which is required as ‘on’=>‘create, update’. But I still getting same bool(false) how can I pass it?
sorry I was thinking wrong way. at index action, there are so many items. my checkexpired() is targeting for one items at a time. I’m sorry. is there any way to solved? I’m really sorry for my wrong logic.
my view file is listing the products. No, my view is not to show only one item. It will show so many items by listing.
there are products. each product has expire date. When I go to the products listing page, I want to know which product is live and which product was expired.
Or, if you really need to save(update) "active" attribute of the products:
// update "active" flags
$products = CompanyLicense::model()->findAll();
foreach($products as $product)
{
$product->active = ($product->checkExpireDate()) ? "ACTIVE" : "EXPIRED";
$product->save();
}
// show list
$model = new CompanyLicense();
if(isset($_GET['CompanyLicense']))
$model->attributes=$_GET['CompanyLicense'];
$this->render('index',array(
'model'=>$model,
));
Note that “$model” in actionIndex is an instance of CompanyLicense model that is meant for the container of search parameters. It doesn’t hold any real data(s) in the database.
@softark, Thx for your code. It is working half . Saving (updating) is not working. Still showing bool(false). when I check by var_dump($product->validate());