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

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()



	// Uncomment the following line if AJAX validation is needed

	// $this->performAjaxValidation($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


but that only works if you are using a model.


How about just


Yii’s scaffolding adds the model because the way the form is generated, submitting a form has nothing to with having a model or not (rather then for example validating/inserting data)

In frameworkless PHP app you can use:

<form action="xpto.php" method="post">

  Field1: <input type="text" name="field1">

  Field2: <input type="text" name="field2">

  <input type="submit">


Then on the xpto.php you could check if the request was a POST with the same maner as:


  $field1 = $_POST['field1'];



  //handle other types of request




Hello JonnyD, welcome to Yii Forum!

I think if you just want to create a custom form, you should use the CFormModel. Also if you just want to render a view, then you just need to pass the view name, e.g.




You can also check the LoginForm.php that is created with the default Yii App.

Both approaches are helpful, thanks guys!