如何将div添加到单选按钮?

use*_*450 2 cakephp radio formhelper cakephp-2.0

我是 CakePHP 的新用户。我正在尝试添加一些 div 来包含我的输入 + 我的标签。

这就是我所拥有的:

<?php 
$option =  array ("value1" => "labelContent1", "value2" => "abelContent2");
echo $this->Form->input('name', array('type' => 'radio', 'options' =>  $option, 'div' => true, "legend" => false));
?>

<div class="input radio">
    <input type="hidden" name="data[Quiz][name]" id="ModelName_" value=""/>
    <input type="radio" name="data[Quiz][name]" id="ModelName1" value="value1" />
    <label for="ModelName1">labelContent1</label>

    <input type="radio" name="data[Quiz][name]" id="ModelName2" value="value2" />
    <label for="ModelName2">labelContent2</label>
</div>       
Run Code Online (Sandbox Code Playgroud)

这就是我想要的:

<div class="input radio">
    <input type="hidden" name="data[Quiz][name]" id="ModelName_" value=""/>
    <div>
        <input type="radio" name="data[Quiz][name]" id="ModelName1" value="value1" />
        <label for="ModelName1">labelContent1</label>
    </div>
    <div>
        <input type="radio" name="data[Quiz][name]" id="ModelName2" value="value2" />
        <label for="ModelName2">labelContent2</label>
    </div>
</div>     
Run Code Online (Sandbox Code Playgroud)

您知道是否可以使用 FormHelper 来制作它?

Pre*_*tam 5

我知道这是一个旧线程,但我不得不回复。在不创建错误标记的情况下实现此目的的正确方法是使用 before 和 after 选项:

echo $this->Form->input('name', array( 'type' => 'radio',
                                     'separator'=> '</div><div>',
                                     'before' => '<div>',
                                     'after' => '</div>',
                                     'options' =>  $option,
                                     'label' => true,
                                     "legend" => false
                                   )
                                );
Run Code Online (Sandbox Code Playgroud)