修复Cakephp Form FIeld类型单选按钮中的选项 [英] Fix the options in Cakephp Form FIeld of type radio button

查看:123
本文介绍了修复Cakephp Form FIeld类型单选按钮中的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类似Cakephp的代码

i am having Cakephp code like

   <?php foreach ($viewfields as $r): 

                          if($r['Attribute']['type']=='radio')
            {

?>

   <script type="text/javascript">
    jQuery.noConflict();
   jQuery(document).ready(function($){


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

    type= "<?=$r['Attribute']['type'];?>";
    attribute_id="<?=$r['Attribute']['id'];?>";
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);
     return i.choice;});  
     }//type==radio
        });//each
 });//jquery

 </script>


<?php


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



 }//if php type == radio

 endforeach; ?>

提醒(i.choice);/提醒我选择性别标签为男性和女性 以及体验为是和否."标签.

alert(i.choice);/alerts me the choices for the label gender as male and female and for the label "experience as yes and no..

如何在选项" => array()中放置男性和女性.请建议我...

How to place male and female in the 'options' => array() ..please suggest me...

推荐答案

您可以尝试一下.


'options' => array( 'Male'=>'Male', 'Female'=>'Female' )

这篇关于修复Cakephp Form FIeld类型单选按钮中的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆