Hi,
I was wondering if anybody else extends controllers for the following reason…
for example, i have an account object and it has child objects such as history, documents, ect…
in my history controller i extend from AccountBaseController… where AccountBaseController looks like this…
public $account;
function __construct($id,$module=null) {
parent::__construct($id,$module=null);
if (isset($_GET["account_id"])){
$account = Account::model()->findByPk($_GET["account_id"]);
if ($account===null){
throw new Exception("There has been an error");
}else{
$this->account = $account;
}
}
}
////////////////////
Does this seem like a reasonable approach?
Otherwise, in the history controller I find myself doing the following…
public function actionUpdate($account_id,$id)
{
//code to save then
$this->redirect($this->createUrl('ViewList',array([color="#0000FF"][b]'account_id'=>$account_id[/b][/color],'id'=>$model->id)));
}
[color="#0000FF"]rather than…[/color]
public function actionUpdate($id)
{
//code to save then
$this->redirect($this->createUrl('ViewList',array([color="#0000FF"][b]'account_id'=>$this->account->id[/b][/color],'id'=>$model->id)));
}