在Cakephp的Form Helper中设置类型单选按钮字段的选项

在Cakephp的Form Helper中设置类型单选按钮字段的选项,cakephp,Cakephp,我正在CakePHP中使用一个表单助手。像 echo $form->input('field', array( 'type' => 'radio','legend'=>$r['Attribute']['label'], // 'after' => '--after--', // 'between' => '--between---', 'separator' => '--separator--', 'options' =

我正在CakePHP中使用一个表单助手。像

   echo $form->input('field', array(
    'type' => 'radio','legend'=>$r['Attribute']['label'],
  // 'after' => '--after--',
    // 'between' => '--between---',
    'separator' => '--separator--',
   'options' => array('1', '2') 
  ));
这让我觉得

<div class="input radio">
 <fieldset>
    <legend>Gender</legend>

     <input type="hidden" value="" id="field_" name="data[field]"/>
     <input type="radio" value="0" id="Field0" name="data[field]"/>
     <label for="Field0">1</label>--separator--
     <input type="radio" value="1" id="Field1" name="data[field]"/>
   <label for="Field1">2</label>

 </fieldset>
</div>

性别
1--分离器--
2.
有没有办法保留我从数据库收到的选项而不是1,2

在那里,我尝试使用

   <?php foreach ($viewfields as $r): ?>
 <script type="text/javascript">
   jQuery.noConflict();

  jQuery(document).ready(function($){


         $("#"+<?=$r['Attribute']['id'];?>).each(function() { 
          type= "<?=$r['Attribute']['type'];?>";

           if(type=="radio")
              {
                   var ht = $.ajax({
                  type: "GET",
                  url: "http://localhost/FormBuilder/index.php/forms/viewChoices/"+attribute_id,
                  async: false
                          }).responseText;

              var myObject = eval('(' + ht + ')');

             var data = myObject;var j=0;

 $.map(data.choices, function(i){ j++; 
   alert(i.choice);//which alerts as male and female correctly.
  return i.choice;});  
             }


        });//each

      });

jQuery.noConflict();
jQuery(文档).ready(函数($){
$(“#”+).each(function(){
类型=”;
如果(类型==“收音机”)
{
var ht=$.ajax({
键入:“获取”,
url:“http://localhost/FormBuilder/index.php/forms/viewChoices/“+属性_id,
异步:false
}).responseText;
var myObject=eval(“(“+ht+”)”);
var数据=myObject;var j=0;
$.map(data.choices,函数(i){j++;
警告(i.choice);//正确地警告男性和女性。
返回i.choice;});
}
});//每个
});

警惕(即选择);正确地提醒选项

如何将这些选项保留在Form Helper的array()中,以便获得这些选项,而不是默认的1,2


请建议我..

将选项放在键=>值数组中-如下所示:

看看你怎么样

echo $form->input('field', array(
  'type' => 'radio',
  'legend' => $r['Attribute']['label'],
  'separator' => '--separator--',
  'options' => array('Male' => 'male', 'Female' => 'female') 
));