Having a strange problem
I want to add a variable to my model but it’s giving me some errors
this is my class in model/VolunteerForm.php
class VolunteerForm extends CFormModel
{
public $name;
public $email;
public $subject;
public $body;
public $verifyCode;
public $special; // THIS DOES NOT WORK???
public $type;
public $day1;
public $day2;
public $day3;
public $day4;
public $day5;
public $day6;
public $day7;
/**
* Declares the validation rules.
*/
public function rules()
{
return array(
// name, email, subject and body are required
array('name, email, subject, body, type', 'required'),
array('special', 'safe'),
array('day1, day2, day3, day4, day5, day6, day7', 'numerical', 'integerOnly'=>true),
// email has to be a valid email address
array('email', 'email'),
// verifyCode needs to be entered correctly
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
);
}
}
and in siteController.php
public function actionVolunteer()
{
$model=new VolunteerForm;
$model->special = Yii::t('general','If you have any special skills enter them here (i.e. First aid, First responder, etc)');
//$model->special = 0;
$model->day1 = 0;
$model->day2 = 0;
$model->day3 = 0;
$model->day4 = 0;
$model->day5 = 0;
$model->day6 = 0;
$model->day7 = 0;
$model->special = "some text";
if(isset($_POST['VolunteerForm']))
{
$model->attributes=$_POST['VolunteerForm'];
if($model->validate())
{
$model->sendEmail($model);
Yii::app()->user->setFlash('volunteer',Yii::t('content','Thank you for contacting us. We will respond to you as soon as possible.'));
$this->refresh();
}
}
$this->render('volunteer',array('model'=>$model));
}
then I call it from my view in view/site/volunteer.php
the form worked great until I added the variable "special". For some reason it keeps telling me that VolunteerForm.special is not defined! This only happens when I load onto the server. When I try locally it works as I would expect.
am I missing something? should that be declared elsewhere?