我尝试创建一个验证表单的驱动程序。因此,在控制器中,我加载驱动程序,然后加载我的验证表单,如下所示:
控制器:
<ComboBox x:Name="cmbSelectText" ItemsSource="{Binding ALT}" DisplayMemberPath="Id" SelectedItem="{Binding SelectedRec}" />
驱动程序:
(...)
$this->load->driver('user');
$this->user->register->validate_form($config);
(...)
错误消息为:
消息:在非对象
上调用成员函数set_rules()任何人都知道这是什么问题?加载了Form_validation。
答案 0 :(得分:0)
You just create a validation class like below
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Validation{
public $v_required ='required|trim';
//Valid name
public $v_name ='trim|min_length[3]|max_length[15]|regex_match[/^[A-Za-z][A-Za-z0-9 .]+$/]';
public $v_name_msg=array('required'=>'Provide %s.','regex_match'=>'Must starts with alphabet,No special chars are allowed.');
}
?>
After call this to your controller like
require_once(APPPATH."controllers/classes/Validation.php");
After creare a object and use validation class
$da=new validation();
$this->form_validation->set_rules('name','Name',$da->v_name,$da->v_name_msg);