1
我試圖在CakePHP中創建一個表單,其中有兩個按鈕:'接受'值= 1,'拒絕'0.一個按鈕與$this->Form->end()
和另一個與$this->Form->submit()
。提交時,數據庫中字段is_accept
的值應更新,0或1取決於用戶選擇單擊哪個按鈕。但我不知道如何設置按鈕的值以及如何將值保存到它。兩個在CakePHP中提交不同值的按鈕
形式:
echo $this->Form->create('Order');
$options = array(
'value' => '0',
'class' => 'btn btn-primary btn-lg pull-right'
);
echo $this->Form->submit('Reject', $options);
$options = array(
'label' => __('Accept'),
'class' => 'btn btn-primary btn-lg',
'value' => '1'
);
echo $this->Form->end($options);
謝謝!我想以同樣的方式生成兩個按鈕。 –
您所寫的代碼無效。表單元素不能有相同的名稱http://stackoverflow.com/questions/11111670/is-it-ok-to-have-multiple-html-forms-with-the-same-name – gmponos
@gmponos我試圖以不同的方式命名兩個按鈕,只需檢查在php中設置了哪個值,以確定哪個按鈕被點擊。即ie [isset($ this-> request-> data ['btw'])){...}'There可能是一個更好的解決方案..你能提供建議嗎?謝謝。 –