用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2796|回复: 6
收起左侧

[HELP] form_validation的'matches[]参数格式是什么?

[复制链接]
发表于 2009-8-27 18:03:31 | 显示全部楼层 |阅读模式
本帖最后由 kazaff 于 2009-8-27 19:02 编辑

刚接触CI,看文档(翻译的不完全,哎~)

set_value()Permits you to set the value of an input form or textarea. You must supply the field name via the first parameter of the function. The second (optional) parameter allows you to set a default value for the form. Example:
<input type="text" name="quantity" value="<dfn><?php echo set_value('quantity', '0'); ?></dfn>" size="50" />
The above form will show "0" when loaded for the first time.
set_select()If you use a <select> menu, this function permits you to display the menu item that was selected. The first parameter must contain the name of the select menu, the second parameter must contain the value of each item, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE).
Example:
<select name="myselect">
<option value="one" <?php echo set_select('myselect', 'one', TRUE); ?> >One</option>
<option value="two" <?php echo set_select('myselect', 'two'); ?> >Two</option>
<option value="three" <?php echo set_select('myselect', 'three'); ?> >Three</option>
</select>
set_checkbox()Permits you to display a checkbox in the state it was submitted. The first parameter must contain the name of the checkbox, the second parameter must contain its value, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE). Example:
<input type="checkbox" name="mycheck[]" value="1" <?php echo set_checkbox('mycheck[]', '1'); ?> />
<input type="checkbox" name="mycheck[]" value="2" <?php echo set_checkbox('mycheck[]', '2'); ?> />
set_radio()Permits you to display radio buttons in the state they were submitted. This function is identical to the set_checkbox() function above.
<input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', TRUE); ?> />
<input type="radio" name="myradio" value="2" <?php echo set_radio('myradio', '2'); ?> />

手册上是怎么说的,不过我不知道它们用在哪里???
发表于 2009-8-27 18:21:33 | 显示全部楼层
set_value()获取validate之后的值

评分

参与人数 1威望 +1 收起 理由
kazaff + 1 3Q

查看全部评分

发表于 2009-8-27 18:45:38 | 显示全部楼层
到底哪里不明白,楼主也没明说啊?

手册翻译都是大家的贡献。
 楼主| 发表于 2009-8-27 18:59:10 | 显示全部楼层
恩,HEX大别着急,我笨~不管大家的事儿
发表于 2009-8-27 19:01:01 | 显示全部楼层
呵呵,说一下你哪里不明白?
 楼主| 发表于 2009-8-27 19:01:06 | 显示全部楼层
$this->form_validation->set_rules('select_test','下拉菜单','matches[1]');
这个参数的参数使用格式是什么?
如果我想定义'select_test'的值必须是1,2,3之间的某一个值,我怎么写?
 楼主| 发表于 2009-8-27 19:03:29 | 显示全部楼层
5# Hex
那个我明白了~~
我又有新问题了哈~

本版积分规则