In Yii how to check a value exist in the database and if its not exist, shows error message below the text box. In controller checks the value is exist, but how show error below the text box when value doesn't exist?
Form is
Thanks
if(isset($_POST['Security']))
{
$answer=$_POST['Security']['security_ans1'];
if($answer==$ans)
{
$this->redirect(array('/postRequest/default/index'));
}
else
{
echo 'error';
}
}
Form is
div class="row">
<?php echo $form->labelEx($model,'Answer'); ?>
<?php echo $form->textField($model,'security_ans1',array('size'=>30,'maxlength'=>50)); ?>
<?php echo $form->error($model,'security_ans1'); ?></td>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
Thanks