php - Cakephp通过foreach在表内单选输入

标签 php html cakephp

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

在纯 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/

相关文章:

php - 单独的 php 文件作为模板 - 安全隐患?

php - PHP vimeo 上的 502 Bad Gateway 使用 NGINX、Laravel Forge 通过 AJAX 上传

php - Yii2:如何使用 mysql db 动态创建页面

html - html5视频标签的css对齐和定位

cakephp - 在 cakePHP 中限制和重定向其他用户

php - 通过 PHPMailer 发送电子邮件时出现身份验证错误

php - 未知的MySQL错误

html - 如何根据 HTML 视频的内​​容保留其高度?

html - 选择并将内容插入到带有 :before with class name does not work 的链接

php - Cakephp 表单必须提交两次才能工作