I’m having the same problem with Yii 1.1.1. I’m following the instructions from the tutorial (http://www.yiiframework.com/doc/guide/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…