用于在Cakephp中创建单选按钮的表单助手 [英] Form helper for creating Radio button in Cakephp

查看:129
本文介绍了用于在Cakephp中创建单选按钮的表单助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个单选按钮使用Cakephp像一个结果应该像

i am trying to create a Radio button using Cakephp like the one the result should resemble like

         <div data-attr="radio" id="1">
          <label id="label1">Untitled1</label><br/>

          <input type="radio" value="option1" id="Radio11" name="Workexperience"/>
          <label for="Radio11">Option1</label>
         <input type="radio" value="option2" id="Radio12" name="Workexperience"/>
         <label for="Radio12">Option2</label>

        </div>

如何使用Form helper生成。
请建议我..

how to generate so using Form helper.. Please suggest me..

推荐答案

这可能有帮助,

http://book.cakephp.org/view/189/Automagic-Form -Elements#options-before-options-between-options-separator-a-191

对于无线电类型输入,'separator'属性可用于注入标记以分隔每个输入/标签对。

For radio type input the 'separator' attribute can be used to inject markup to separate each input/label pair.

代码视图

<?php echo $form->input('field', array(
    'before' => '--before--',
    'after' => '--after--',
    'between' => '--between---',
    'separator' => '--separator--',
    'options' => array('1', '2'),
    'type' => 'radio'
));?>

输出:

<div class="input">
--before--
    <input name="data[User][field]" type="radio" value="1" id="UserField1" />
    <label for="UserField1">1</label>
--separator--
    <input name="data[User][field]" type="radio" value="2" id="UserField2" />
    <label for="UserField2">2</label>
--between---
--after--
</div>

这篇关于用于在Cakephp中创建单选按钮的表单助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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