In view file I have
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'userregistration-registration-form',
'enableAjaxValidation'=>false,
)); ?>
<?php echo $form->textField($model,'fname', array("id"=>"txtSignUpName", "name"=>"txtSignUpName", "style"=>"border:1px solid #DCDCDD")); ?>
In model:
public function rules()
{
return array(
array('title, fname, lname, residence, contactType, contactNumber, gender, email, password, confrimpassword, admin', 'required'),
..................
);
}
public function attributeLabels()
{
return array(
'fname' => 'First Name',
.....................
In controller:
public function actionRegistration()
{
$model=new Userregistration('register');
if(isset($_POST['Userregistration']))
{
$model->attributes=$_POST['Userregistration'];
print_r($_POST);
if($model->validate())
{
$model->save();
$this->actionIndex();
}
}
$this->render('registration',array('model'=>$model));
}
if($model->validate()) is not returning true. why ?
When I submit the form after filling all the fields I get these errors on top
Please fix the following input errors:
Title cannot be blank.
First Name cannot be blank.
Last Name cannot be blank.
Residence cannot be blank.
Contact Type cannot be blank.
Contact Number cannot be blank.
Gender cannot be blank.
Email cannot be blank.
Password cannot be blank.
print_r($_POST); gives otuput
Array ( [ddltitle] => Capt. [txtSignUpName] => dasda [txtLastName] => dasda [ddlNationality] => Albania [ddlCountry] => Albania [ddlContactType] => Mobile [Country_Code] => 321 [Area_Code] => 321 [Contact_number] => 3231 [gender] => Male [txtSignUpEmail] => asda@sd.com [txtSignUpConfirmPassword] => asdfg [Userregistration] => Array ( [confrimpassword] => asdfg [admin] => 0 ) [Register] => )