CakePHP - switch that does not display an error message

I cannot get an error when creating a radio form using the CakePHP form assistant.

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 am using CakePHP 1.2.7 and this is what I have in validation

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

I tried the answer from the Form Helper to create the Radio button in CakePHP , and instead it provided me with a selection form.

Thanks,
Tee

+4
source share
6 answers

there was the same problem, and I create it, and it works:

http://book.cakephp.org/view/204/Form-Element-Specific-Methods

you need

 if ($form->isFieldError('gender')){ echo $form->error('gender'); } 

... in your code. this works if your field is named as gender.

+4
source

I had the same problem and I added:

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

under the switch, and it worked fine.

+2
source

Try looking at $ form-> input ("Status" ... (capital "Status") compared to the DB column name (which may or may not be capitalized compared to "name" => 'data [Entry] [status ] '(not capital status).

The cupcake form assistant is picky about inserting error messages when he cannot figure out what the matter is.

+1
source

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

0
source

You need to manually add the error form helper.

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

0
source

You need to add an error condition in the case of a radio button

 <?php $options=array('active'=>'Active','inactive'=>'Inactive'); echo $form->input('Status', array( 'type' => 'radio', 'id' => 'EntryStatus', 'options' => $options ) ); if ($form->isFieldError('Status')){ echo $form->error('Status'); } ?> 
0
source

Source: https://habr.com/ru/post/1308811/


All Articles