CakePHP "Agree TOS" Checkbox Validation

Viewed 9290

I am trying to have a Checkbox "Agree TOS".

If the Checkbox is not checked, I want to put out a Flash Message.

How do I do this?

My View:

<?php   
        echo $form->create('Item', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));
        echo $form->input('Search', array('div' => false));
        echo $form->submit(__('Search', true), array('div' => false));
        echo $form->checkbox('tos', array('label' => false, 'value'=>1)).' Agree TOS'; 
        echo $form->error('tos');
        echo $form->end();
?>

My Model:

var $check = array(
            'tos' => array(
               'rule' => array('comparison', 'equal to', 1),
               'required' => true,
               'allowEmpty' => false,
               'on' => 'index',
               'message' => 'You have to agree TOS'
               ));
6 Answers
Related