when i called controller then show Error 404 The system is unable to find the requested action "index".
its Test controller file
class TestController extends Controller
{
public function actionLogin()
{
$model=new SignupForm();
if(isset($_POST['SignupForm']))
{
// collects user input data
$model->attributes=$_POST['SignupForm'];
// validates user input and redirect to previous page if validated
if($model->validate())
$this->redirect(Yii::app()->user->returnUrl);
}
// displays the login form
$this->render('index',array('model'=>$model));
}
}
Its model File
class SignupForm extends CFormModel
{
public $username;
public $password;
public $rememberMe=false;
public function rules()
{
return array(
array('username, password', 'required'),
array('rememberMe', 'boolean'),
array('password', 'authenticate'),
);
}
public function authenticate($attribute,$params)
{
$this->_identity=new UserIdentity($this->username,$this->password);
if(!$this->_identity->authenticate())
$this->addError('password','Incorrect username or password.');
}
}
When i called controller then show Error 404 The system is unable to find the requested action "index" so how to fixed this error
Action "index" is the default action in Yii controllers. You can change this behavior, setting you default index of a particular controller.
class TestController extends Controller
{
public $defaultAction = 'login';
public function actionLogin()
{
}
}
In this case, when you run /index.php?r=test will be like /index.php?r=test/login.
There is no actionIndex() method in your controller. So either call www.yourwebsite.com/index.php?r=test/login or create an actionIndex() method in your test controller.