Yii Framework Forum: Controller cannot find view - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Controller cannot find view Rate Topic: -----

#1 User is offline   Arvind 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 03-October 09
  • Location:Calgary, AB, Canada

Posted 21 October 2009 - 01:23 AM

Hello,

I am constanly getting this message.
USERSController cannot find the requested view "list".

when i try to access this url
http://localhost/spi....php/USERS/list

Now, there is a directory called USERS and it has a file called list.php.

Alternately if i try to open the url like this
http://localhost/spi...php/USERS/lista

then it says
The system is unable to find the requested action "lista".

So i guess, I am missing something very small. Can somebody please help me ?

thanks
Arvind
0

#2 User is offline   Arvind 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 03-October 09
  • Location:Calgary, AB, Canada

Posted 21 October 2009 - 01:32 AM

I put in some debugging code.. and i found this

public function actionList()
{
$criteria=new CDbCriteria;

$pages=new CPagination(USERS::model()->count($criteria));
$pages->pageSize=self::PAGE_SIZE;
$pages->applyLimit($criteria);

$models=USERS::model()->findAll($criteria);
echo "i reached here";
exit;
$this->render('list',array(
'models'=>$models,
'pages'=>$pages,
));
}

It prints out "I reached here".

and then it does not like the render part. Keeps complaining that the view list does not exist.

i am sure, its something small that i am missing.

thanks
Arvind
0

#3 User is offline   Scott Deagan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 70
  • Joined: 04-February 10

Posted 18 August 2010 - 09:20 AM

I'm having the same problem with Yii 1.1.1. I'm following the instructions from the tutorial (http://www.yiiframew...ide/form.action) but seem to be missing something.

I'm trying to 0create a registration (signup) form.

My model is protected/models/SignupForm.php:
<?

  class SignupForm extends CFormModel
  {
    public $username;
    public $password_one;
    public $password_two;
    public $password_hint;
    public $msisdn;
    public $email;
    public $secret_question;
    public $secret_answer;
    public $account_type;
    
    public $xml_response;
    
    public function rules()
    {
      return array(
        array('username,password_one,password_two,password_hint,msisdn,email,secret_question,secret_answer,account_type', 'required'),
        array('password_one, password_two', 'email'),
      );
    }
       
  }
?>


My controller is protected/controllers/TestHarnessController.php:

<?
  class TestHarnessController extends Controller
  {
    public function actionSignup()
    {
      $model = new SignupForm();
      if (isset($_POST['SignupForm']))
      {
        // Collect user input data...
        $model->attributes = $_POST['SignupForm'];
        
        // Validate user input and redirect to previous page if validated...
        if ($model->validate())
          $this->redirect(Yii::app()->user->returnUrl);
      }
      
      // Display the Signup form...
      $this->render('signup', array('model' => $model));
    }    
  }
?>


The view I want to display is protected/views/testharness/signup.php:

<?php
$this->pageTitle=Yii::app()->name . ' - Sign Up Test';
$this->breadcrumbs=array(
	'Signup Test',
);
?>

<h1>Sign-up</h1>

<p>Enter valid credentials to create a new account:</p>

<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'signup-form',
	'enableAjaxValidation'=>true,
)); ?>


<?php $this->endWidget(); ?>
</div><!-- form -->


Any help would be really appreciated...
0

#4 User is offline   Scott Deagan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 70
  • Joined: 04-February 10

Posted 18 August 2010 - 09:28 AM

I found the problem - the first letter of the directory created in protected/views cannot start with a capital letter (on Linux systems anyway).

I had the following directory:

protected/views/TestHarness/

This resulted in the "Controller cannot find view" error. When I changed the directory name to:

protected/views/testHarness/

then everything works as expected.
1

#5 User is offline   Cristiano Souza 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 10-November 11

Posted 16 November 2011 - 08:55 AM

Thanks a lot Scott Deagan!

I had the same problem.
The directory was:
protected/view/PCombustiveis

After change to protected/view/pCombustiveis its work!

Many thanks!
Please, excuse my poor english.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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