Ads

Exclusive Prizes----> Click Here
Showing posts with label Cakephp. Show all posts
Showing posts with label Cakephp. Show all posts

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.