I am trying to save a value from a form , somewhat unsuccessfully and I am struggling to find out what i am doing wrong.
Here’s the scenario
I have a form that posts a new job to the database, I have a checkbox within that called ‘email_cust’, which when checked should send an email to the customer letting them know a job has been created,
the code in the view is
<?php echo $form->labelEx($model,‘email_cust’); ?>
<?php echo $form->checkBox($model,‘email_cust’, array(‘value’=>1, ‘uncheckValue’=>0)); ?>
and in my controller i am trying to do
if ($model->email_cust == 1) {
$mail = new YiiMailer();
$mail->setFrom('support@mydomain.co.uk', 'My comapany ');
$mail->setTo($model->customer->email);
$mail->setSubject('test');
$mail->setBody('test');
$mail->send();
}
i have a public variable in the model called $email_cust and it is set to safe
any ideas as to why this is not working, or am i going about it the wrong way ?