function getErrors()

Hey all,

I’m new to the Yii Framework and have ran in to a problem which i just cant seem to get my head around as of yet! My goal is to develop a registration system and then develop it further and further in to a User management System.

So here comes the issue!

My root folder contains the following

  • Components

  • config

  • controllers

  • models

  • views

Components Consists off my BaseController.php


class BaseController extends CController {

	public function init() {

		

		// Default Page Name

		$this->pageTitle = Yii::app()->name;

		/**

		 *	Paths to assets

		 */

		define('BASE_URL', Yii::app()->baseUrl);

		define('IMG_PATH', BASE_URL.'/images');

		define('CSS_PATH', BASE_URL.'/css/'); // CSS

		define('BASE_PATH', str_replace('protected', '', Yii::app()->basePath));

		


		

	}

	

}

Configconsists of main.php


<?php

return array(

	

	// Site Name

	'name' => 'BluPrint',

	

	// Imports

	'import' => array(

		'application.models.*',

		'application.models.armodels.*',

		'application.models.formmodels.*',

		'application.components.*'

	),

	

	'components' => array(

		

		// Core Configuration Setup

		'db' => array(

			'class' => 'CDbConnection',

			'connectionString' => 'mysql:host=localhost;dbname=reg',

			'username' => 'root',

			'password' => '',

			'emulatePrepare'=>true,

		),

		),

);

Controllers consists of SiteController.php


<?php


class SiteController extends BaseController {

	public function actionIndex() {

		

		$this->render('index');

		

	}

}

Models consists off AuthForm.php


<?php

class authForm extends CFormModel

{

public $password2;

public $verifyCode;

	

	public function rules()

	{

	 array('username','length','max'=>32),

                        // convert username to lower case

                        array('user_name', 'filter', 'filter'=>'strtolower'),

                        array('password','length','max'=>64, 'min'=>6),

                        array('password2','length','max'=>64, 'min'=>6),

                        // compare password to repeated password

                        array('password', 'compare', 'compareAttribute'=>'password2'), 

                        array('email','length','max'=>256),

                        // make sure email is a valid email

                        array('email','email'),

                        // make sure username and email are unique

                        array('user_name, email', 'unique'), 

                        // verifyCode needs to be entered correctly

                        array('verifyCode', 'captcha', 'allowEmpty'=>!extension_loaded('gd')),

                );


	}

?>

View Consists of site -> Index.php


<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/formone.css" />

<title>Registration Form</title>


</head>


<body>

<div id="container">

<div id="banner"></div>

<div id="regWrapper">

<div id="header"></div>

<div id="content">

  <p>&nbsp;</p>

<h1>Username</h1>

  <p>Please Enter your desired Username into the Field Below:</p>

<fieldset>

		<legend>Registration</legend>

		<?php echo CHtml::beginForm() ?>

 		<?php echo CHtml::errorSummary($authForm); ?>


        <div class="row">

        <?php echo CHtml::error($authForm, 'user_name'); ?>

        <?php echo CHtml::activeLabel($authForm, 'user_name', array('class' => 'texta', 'small')); ?>

        <?php echo CHtml::activeTextField($authForm, 'user_name', array('class' => 'texta', 'large')); ?>

        </div><!-- USER NAME END -->

        <h1>E-Mail Address</h1>

        <p>Please enter a valid email address to complete this registration process, as it is needed to activate your account</p>

        <div class="row">

		<?php echo CHtml::error($authForm, 'email'); ?>

		<?php echo CHtml::activeLabel($authForm, 'email', array('class' => 'texta', 'small')); ?>

		<?php echo CHtml::activeTextField($authform, 'email', array('class' => 'texta', 'large')); ?>

        </div><!-- EMAIL END -->

        <h1>Password</h1>

        <p>Please enter your password below, the two passwords must match</p>

        <div class="row">

        <?php echo CHtml::error($authForm, 'password'); ?>

        <?php echo CHtml::activeLabel($authForm, 'password', array('class' => 'texta', 'small')); ?>

        <?php echo CHtml::activePasswordField($authForm, 'password', array('class' => 'texta', 'large')); ?>

        </div>

          <div class="row">

        <?php echo CHtml::error($authForm, 'password2'); ?>

        <?php echo CHtml::activeLabel($authForm, 'password2', array('class' => 'texta', 'small')); ?>

        <?php echo CHtml::activePasswordField($authForm, 'password2', array('class' => 'texta', 'large')); ?>

        </div>

        <h1>Profile Details</h1>

        <p>Please Fill in the following Information about yourself, this information can always be changed once registration is complete</p>

        <div class="row">

        <p>Forename</p>

        <?php echo CHtml::error($authForm, 'forename'); ?>

		<?php echo CHtml::activeLabel($authForm, 'forename', array('class' => 'texta', 'small')); ?>

		<?php echo CHtml::activeTextField($authForm, 'forename', array('class' => 'texta', 'large')); ?>

        </div><!-- ENDING FORENAME -->

        <div class="row">

        <p>Surname</p>

        <?php echo CHtml::error($authForm, 'surname'); ?>

		<?php echo CHtml::activeLabel($authForm, 'surname', array('class' => 'texta', 'small')); ?>

		<?php echo CHtml::activeTextField($authForm, 'surname', array('class' => 'texta', 'large')); ?>

       </div>

       <?php if(extension_loaded('gd')): ?>

		<div class="row">

        <?php echo CHtml::activeLabel($authForm,'verifyCode', array('style'=>'width:150px;')); ?>

        <div>

        <?php $this->widget('CCaptcha'); ?>

        <?php echo CHtml::activeTextField($authForm,'verifyCode'); ?>

        </div>

        <p class="hint">Please enter the letters as they are shown in the image above.

        <br/>Letters are not case-sensitive.</p>

</div>

<?php endif; ?>

<div class="action">

<?php echo CHtml::submitButton('Register'); ?>

</div>


<?php echo CHtml::endForm(); ?>


       </form>

        </fieldset>




</div>

</div>

</div>




</div><!--container -->




</body>

</html>



And when it is displayed in the browser window i get the following error!

[b]

Fatal error: Call to a member function getErrors() on a non-object in C:\wamp\www\Yii\framework\web\helpers\CHtml.php on line 1407[/b]

I would appreciate any help on this as it is tearing away at my brain for the last two days!

Kind Regards

N3R

$authForm is not passed onto your view.

$this->render(‘index’, array(‘authForm’=>$yourdata)) in your SiteController.

Welcome to the forums!