Chinaunix首页 | 论坛 | 博客
  • 博客访问: 532093
  • 博文数量: 119
  • 博客积分: 3167
  • 博客等级: 中校
  • 技术积分: 1215
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-20 21:21
文章分类

全部博文(119)

文章存档

2015年(21)

2012年(4)

2011年(1)

2007年(11)

2006年(50)

2005年(32)

分类:

2007-09-17 12:59:47

fleaphp+smarty中forms的写法
$value数组如下

Array

(

    [8] => second

    [7] => 第二个

    [9] => third

)

多选框

<{webcontrol type='checkboxgroup' name='check' items=$value multirow=true cols=2 selected='second' }>

其中$value为一个数组,内容为Array('索引'=>'值'),索引为显示的部为,值为checkbox的值,selected=值,则该值为选中项,若selected=数组

刚可以中多个,该例子中会选中多选框值为second的框

单选框

<{webcontrol type='radiogroup' name='radio' items=$value multirow=true cols=2 selected='third' }>

说明同上

文本框

<{webcontrol type='textbox' name='check' value='文本框' size=100   }>

密码框

<{webcontrol type='password' name='check' value='文本框' size=100   }>

提交框

<{webcontrol type='submit' name='check' value='提交' }>

重置

<{webcontrol type='reset' name='check' value='重置    }>

文件

<{webcontrol type='fileUpload' name='file1'}>


<{webcontrol type='fileUpload' name='file2'}>

下拉列表

<{webcontrol type='DropdownList' name='test' items=$value }>

文本区
<{webcontrol type="memo"}>

若$value数组为

Array

(

    [0] => Array

        (

            [post_id] => 8

            [title] => second

            [body] => second

            [created] => 2007-04-02 09:20:29

        )



    [1] => Array

        (

            [post_id] => 7

            [title] => 第二个

            [body] => 第二个的内容

            [created] => 2007-03-31 18:04:58

        )



    [2] => Array

        (

            [post_id] => 9

            [title] => third

            [body] => third'body

            [created] => 2007-04-02 09:24:11

        )



)

则多选框写法如下:

多选框

<{webcontrol type='checkboxgroup' name='check' items=$value multirow=true cols=2 selected='second' key='title' caption='post_id'}>

结果是标签为caption及7,8,9值为key及second,第二个,third等,值为second的那个选中

下拉列表

<{webcontrol type='DropdownList' name='test' items=$value key='post_id' caption='title' selected='9'}>

则key为值,caption为显示在下拉列表中的标签.,值为9,就是caption为third的选中



另:如果catpion中有相同的项,刚只显示最后一项

以上只是做测试用。具体应用时,selected是哪一项,从数据库中的相应字段读出
阅读(1968) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~