Ads

Exclusive Prizes----> Click Here

Thursday, June 14, 2012

Radio Buttons validation in cakephp

Usually cakephp doesn't validate the radio buttons, to re-produce that,

Step1:

In View:

<?php echo $form->radio('myfield',array(OPTIONS));?>

Step2:

After,  <?php if(!empty($this->data)){


if(empty($this->data[MODEL]['myfield'])){$this->set('radioerror','ERROR MSG');}


NOW ALTER VIEW:


<?php echo $form->radio('myfield',array(OPTIONS));?>
 <div class="error-message">
 <?php if (isset($radioerror)){echo $radioerror;}?>


</div>

THAT'S IT.

1 comment:

Thank you for your comment