tags:

views:

315

answers:

4

Hi,

I'm unable to get the error message to show up when creating a radio form using the CakePHP form helper.

This is what I have now.

     $options=array('active'=>'Active','inactive'=>'Inactive');
     echo $form->input('Status', array(
  'type' => 'radio',
  'id' => 'EntryStatus',
  'name' => 'data[Entry][status]',
  'options' => $options

));

What am I missing?
I'm using CakePHP 1.2.7 and this is what I have in the validation

'status' => array(
    'notempty' => array(
         'rule' => 'notempty',
         'required' => true,
         'message' => 'yo'
         )
    )

Tried the answer from http://stackoverflow.com/questions/1388823/form-helper-for-creating-radio-button-in-cakephp and it's giving me a select option form instead.

Thanks,
Tee

A: 

Have you tried using the explicit $form->radio() method instead of the general input() method?

Don Kirkby
Hi @Don Kirkby, yes I tried using $form->radio() method as well. Basically the validation works in that form isn't submitted if the radio button isn't selected. However, the error message that typically shows up below the form isn't showing up and that error message is what I'm trying to figure out since that should theoretically be a built in capability of the form helper.
teepusink
A: 

Try taking a look at $form->input('Status' ... (capital 'Status') versus the DB column name (which might or might not be capitalized versus 'name' => 'data[Entry][status]' (not capital 'status').

Cake's form helper is picky about inserting error messages when it can't figure out what things go to what.

Christian Winebrenner
A: 

You need to manually add in an error form helper.

echo $form->error('status');

Ahmer Zaidi
A: 

I had the same issue and I added:

<?php echo $form->error('currentStatus');?>

below the radio button and it worked fine.