2016-03-08 23 views
0

我已经创建了一个表单。只需输入字段,一切正常。但现在我使用复选框作为类型,它只是发送一个01,无论我检查与否。CakePHP 3使用Form Helper和Checkox

echo $this->Form->input('phone', ['type' => 'checkbox', 'label' => ['text' => __('Telefon/Handy'), 'class' => 'moCheckLabel']]); 

也为单选按钮,但只是一个空洞的一个又一个与0

echo $this->Form->radio(
       'type', 
       [ 
        ['value' => '0', 'text' => __('Move'),], 
        ['value' => '1', 'text' => __('Just'),], 
       ], ['label' => ['class' => 'moCheckLabel']] 
      ); 

这使得没有SENCE对我来说,任何想法?

编辑:问题一解决了。单选按钮仍然是一个神秘的:/

echo $this->Form->input('phone', ['type' => 'checkbox','hiddenField' => '0', 'label' => ['text' => __('Telefon/Handy'), 'class' => 'moCheckLabel']]); 
+0

你试过了[API](http://book.cakephp.org/3.0/en/views/helpers/form.html#creating -radio-按钮) – ArchLicher

回答

0

好的,谢谢,我可能会读这个。

echo $this->Form->radio(
      'type', 
      [ 
       ['value' => '0', 'text' => __('Move'),], 
       ['value' => '1', 'text' => __('Just'),], 
      ], ['label' => ['class' => 'moCheckLabel'], 'hiddenField' => false] 
     ); 

'hiddenField'=>虚假的伎俩