CakePHP“同意TOS”复选框验证

前端之家收集整理的这篇文章主要介绍了CakePHP“同意TOS”复选框验证前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图有一个复选框“同意TOS”.

如果未选中复选框,我想放出一个Flash消息.

我该怎么做?

我的看法:

<?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();
?>

我的型号:

var $check = array(
            'tos' => array(
               'rule' => array('comparison','equal to',1),'required' => true,'allowEmpty' => false,'on' => 'index','message' => 'You have to agree TOS'
               ));
这似乎适合我.希望会有所帮助.

型号:

'tos' => array(
                'notEmpty' => array(
                    'rule'     => array('comparison','!=',0),'message'  => 'Please check this Box if you want to proceed.'
                )

看来:

<?PHP echo $this->Form->input('tos',array('type'=>'checkBox','label'=>__('I confirm I have read the <a href="/privacy-statement">privacy statement</a>.','hiddenField' => false,'value' => '0')); ?>
原文链接:https://www.f2er.com/php/132229.html

猜你在找的PHP相关文章