2013年11月4日

摘要: test controller:test.php:load->helper('url'); $this->load->helper('form'); }function index(){ $this->load->library('form_validation'); $data['main_content'] = 'form_check'; $this->load->view('includes/template',$data); }function ch 阅读全文
posted @ 2013-11-04 17:41 以为是帅哥 阅读(698) 评论(0) 推荐(0) 编辑
 
摘要: CI中的表单辅助函数 载入辅助函数:$this->load->helper('form'); 1、form标签函数:form_open()$attributes = array('class' => 'email', 'id' => 'myform');echo form_open('email/send', $attributes);创建一个这样的form标签:2、增加隐藏域:$hidden = array('username' => 'Joe 阅读全文
posted @ 2013-11-04 16:29 以为是帅哥 阅读(592) 评论(0) 推荐(0) 编辑
 
摘要: 在CI框架中如何添加新的表单规则呢?比如,我想在进行表单验证的时候,添加一个电话号码的验证规则,或是一个手机号码的验证规则。我在框架中做了如下偿试,但没有成功:首先,我找到了/system/libraries/目录下的Form_validation.php和Validation.php,并在两个文件的最后面添加了以下方法:1.) function phone($str) { return ( ! preg_match("/^0\\d{2}[-]?\\d{8}$|^0\\d{3}[-]?\\d{7}$/", $str)) ? FALSE : TRUE; } ... 阅读全文
posted @ 2013-11-04 13:41 以为是帅哥 阅读(631) 评论(0) 推荐(0) 编辑