簡體   English   中英

用cakephp 1.3生成廣播

[英]Generate radio with cakephp 1.3

我需要像這樣生成蛋糕PHP格式的單選按鈕

<div class="radioset gender">
<div>
    <div>Male</div>
    <label>
        <input type="radio" name="sex" value="1"/>
    </label>
</div>
<div>
    <div>Female</div>
    <label>
        <input type="radio" name="sex" value="0"/>
    </label>
</div>

我不能使用

e($form->radio("User.sex",array(0=>"Male",1=>"Female"),array("legend"=>false)));

因為它不能生成我想要的HTML格式。 我這樣使用多輸入

e($form->input( 'User.sex', array('type'=>'radio', 'options' => array(0=>""),'div'=>false, "error"=>false, 'label' => false ) ));
e($form->input( 'User.sex', array('type'=>'radio', 'options' => array(1=>""),'div'=>false, "error"=>false, 'label' => false ) ));

但是當我提交表格時。 服務器無法獲得價值。 請幫我怎么做。 謝謝。

使用以下格式:

 echo $form->input('field', array(
'type' => 'radio',
'legend'=>'Group of Radio',
// 'after' => '--after--',
// 'between' => '--between---',
'separator' => '--separator--',
'default' => '--which is by default selected--',
  'options' => array('Button One', 'Button Two')
 ));

您可以使用Separator做到這一點。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM