我想要表格内的单选按钮,没有标签,一个表格行有一个单选按钮,同时所有分组在一个组中,因此用户可以通过从组中选择一个单选按钮来选择单个表格行 ...
在纯 html 中它看起来像这样:
<div class="radio">
<label>
<input type="radio" name="memberPaymentsRadio" value="mp<?php echo $key;?>" aria-label="...">
</label>
</div>
要获得相同的 html 代码,cakephp 中的代码是什么?
我试过这样的:
foreach($payments as $key => $payment){
...
echo $form->input('memberPaymentsRadio',
array(
'div' => array('class' => 'radio'),
'label' => false,
'type' => 'radio',
'aria-label' => '...',
'options' => array('mp'.$key),
'before' => '<label>',
'after' => '</label>'
)
);
}
但是我得到了单选按钮,每个表行一个,并且都在特定的表列中,但带有标签“mp0”、“mp1”,这不是我要找的...
最佳答案
你可以这样使用
$this->Form->radio('memberPaymentsRadio', array('mp'.$key => ""),array('class' => 'radio', 'before' => '<label>','after' => '</label>','label' => false));
关于php - Cakephp通过foreach在表内单选输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30238907/