Yii Framework Forum: How to set errorAction for module? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to set errorAction for module? Rate Topic: -----

#1 User is offline   _wk_ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 152
  • Joined: 22-January 10

Posted 06 August 2010 - 10:00 AM

I'm trying to set a different error action for an admin module. I've tried in various ways (see below) but cannot get it to work. Any ideas?

class AdminModule extends CWebModule
{
	public function init()
	{
		// import the module-level models and components
		$this->setImport(array(
			'admin.models.*',
			'admin.components.*',
		));
		
		$this->setComponents(array(
			'errorHandler'=>array(
					'errorAction'=>'/admin/default/error'
				)
		));
	}


class AdminModule extends CWebModule
{
	public function init()
	{
		// import the module-level models and components
		$this->setImport(array(
			'admin.models.*',
			'admin.components.*',
		));
		
		Yii::app()->errorHandler->errorAction='/admin/default/error';
		
	}
	
}

0

#2 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,035
  • Joined: 30-October 09
  • Location:UK

Posted 06 August 2010 - 10:18 AM

Do it like this:

public function init()
{
	parent::init();
	Yii::app()->setComponents(array(
		'errorHandler'=>array(
			'errorAction'=>'admin/default/error',
		),
	));
		
	// import the module-level models and components
	$this->setImport(array(
		'admin.models.*',
		'admin.components.*',
	));
}

0

#3 User is offline   _wk_ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 152
  • Joined: 22-January 10

Posted 06 August 2010 - 10:28 AM

Thanks for this, it now works!
0

#4 User is offline   Nisanth thulasi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 10-July 12
  • Location:Kochi

Posted 13 February 2013 - 08:12 AM

AdminModule.php add init() as below

 

	parent::init();
		Yii::app()->setComponents(array(
		'errorHandler'=>array(
		'errorAction'=>'admin/default/error',
		),
		));

Thanks
Nisanth Thulasi
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users