Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Missing Argument 1 For Mycontroller::loadmodel()

$
0
0
Hello.
I have problem with passing $id to function loadModel($id), which is executed inside my own filter "filterViewOwn". I have error: Missing argument 1 for PostController::loadModel(). Does anyone can help me? How can i pass this $id? Thanks, greetings.

	public function filters()
	{
		return array( 
                        'viewOwn + view',
                        'rights',                        
			);
	}

	public function filterViewOwn($filterChain)
	{
		$post=$this->loadModel();
		// Remove the 'rights' filter if the user is updating an own post
		// and has the permission to do so.
		if(Yii::app()->user->checkAccess('PostViewOwn', array('userid'=>$post->author_id)))
		$filterChain->removeAt(1);
		$filterChain->run();
	} 

	public function loadModel($id)
	{
		$model=Post::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}

Viewing all articles
Browse latest Browse all 18717

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>