【问题标题】:Cakephp Radio input within table through foreach通过foreach在表内进行Cakephp Radio输入
【发布时间】:2015-05-14 13:41:15
【问题描述】:

我想要表格中的单选按钮,没有标签,一个表格行有一个单选按钮,而所有这些都分组在一个组中,因此用户可以通过从组中选择一个单选按钮来选择单个表格行...

在纯 html 中是这样的:

<div class="radio">
    <label>
        <input type="radio" name="memberPaymentsRadio" value="mp<?php echo $key;?>" aria-label="...">
    </label>
</div>

cakephp 中的代码是什么来获得相同的 html 代码?

我试过这样:

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”,这不是我想要的......

【问题讨论】:

  • 尝试改变这个标签,before,after 为 'label' => '' , 'before' => '','after' => ''

标签: php html cakephp


【解决方案1】:

你可以这样使用

$this->Form->radio('memberPaymentsRadio', array('mp'.$key => ""),array('class' => 'radio', 'before' => '<label>','after' => '</label>','label' => false));

【讨论】:

    猜你喜欢
    • 2013-01-16
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 2016-09-27
    • 1970-01-01
    • 2010-12-24
    • 2013-05-15
    相关资源
    最近更新 更多