// IAM試圖加載與輸入數組和檢查,然後輸入如何設定規則,表單驗證我的自定義庫中的笨
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Slider{
public $ci;
public $ci2;
protected $CI;
function __construct() {
// reference to the CodeIgniter super object
$this->CI =& get_instance();
$this->ci =&get_instance();
$this->ci->load->model('Slider_Model');
$this->CI->load->library('form_validation');
}
//負荷數組保存數據的輸入和檢查輸入,然後保存數據enter image description here
function AddSlide($Data){
$this->CI->load->library('form_validation');
$this->CI->form_validation->set_error_delimiters('<p style="color: red">', '</p>');
$this->CI->form_validation->set_rules($Data['Title'],$Data['Title'],'min_length[5]|max_length[20]');
$this->CI->form_validation->set_rules($Data['Description'],$Data['Description'],'min_length[10]|max_length[100]');
$this->CI->form_validation->set_rules($Data['Status'],$Data['Status'],'in_list[1,2]');
if ($this->CI->form_validation->run() == FALSE)
{
echo FALSE;
}
else
{
$this->ci->Slider_Model->AddNewSlid($Data);
}
}
}
詞不等於CI。確保$ this-> ci是$ this-> CI –