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

Is There A Way To Submit A Form To The Same Controller/action That Rendered The View Without A Model?

$
0
0
From examples I have seen the only way to submit a form back to the controller/action that rendered it is if you used a model in the view, for example:

public function actionLogin()
{
	$model=$this->loadModel($id);

	// Uncomment the following line if AJAX validation is needed
	// $this->performAjaxValidation($model);

	if(isset($_POST['User']))
	{
		$model->attributes=$_POST['User'];
		if($model->save())
			$this->redirect(array('view','id'=>$model->id));
	}

	$this->render('login',array(
		'model'=>$model,
	));
}


but what if I have a custom controller/action and custom form that doesn't have a model? How would I check if it was submitted? In the above example you can simply use
if(isset($_POST['User']))
but that only works if you are using a model.

Thanks

Viewing all articles
Browse latest Browse all 18717

Trending Articles



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