2016-03-08 65 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'=>虛假的伎倆