4
好吧我試圖將參數傳遞給我創建的庫的構造函數,以擴展CI_Form_validation類。 總之,這裏是我從我的模型傳遞什麼:CodeIgniter params沒有傳遞給庫?
$this->load->library('MY_Form_validation', array('config' => '', 'post' => $this->input->post()));
然後這裏是MY_Form_validation庫:
private $post;
public function __construct($params) {
parent::__construct($params['config']);
$this->post = $params['post'];
}
但它說我沒有通過任何東西這裏有錯誤。消息:
Message: Missing argument 1 for MY_Form_validation::__construct(), called in H:\WD SmartWare.swstor\HALEY-HP\Source\DStable\stable\core\Loader.php on line 1099 and defined
Message: Undefined variable: params
EDIT 根據要求,整個類:
class MY_Form_validation extends CI_Form_validation {
private $post;
public function __construct($params) {
parent::__construct($params['config']);
$this->post = $params['post'];
}
}
您是否在其他地方加載了form_validation庫?具體在自動裝載機? – Laurence
等什麼?如果你在自動加載器中加載類,它是否加載到所有地方?我沒有在任何地方加載它。其實,我正在將它加載到register.php控制器中!這是否重要? – Peanut
你可以發佈你的my_form_validation的類聲明嗎? – Laurence