![]() |
Extend Form_Validation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Extend Form_Validation (/showthread.php?tid=64858) |
Extend Form_Validation - lucavalentino - 04-04-2016 I use Codeigniter 3.0.6 I want extend the library Form_Validation but not received a personal message error MY_validation extends CI_Form_validation PHP Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); My controller PHP Code: class valid extends MY_Controller{ In the View print an errors echo validation_errors(); see {url} and not personal message. Help me RE: Extend Form_Validation - Tpojka - 04-04-2016 You should use visibility attribute in parent class. Since version 5.3.3 (which is some 6 years now), method with same name as class are replaced with __construct(). Class names in CI3 should be ucfirst treated. You should make it in way docs propose `MY_Form_validation extends CI_Form_validation{}`. Prefix `MY_` shouldn't be used when file is called/class is loaded. `$this->My_validation->set_message` can be `$this->form_validation->set_message`. RE: Extend Form_Validation - InsiteFX - 04-04-2016 It should also be named MY_Form_validation not MY_validation. RE: Extend Form_Validation - lucavalentino - 04-04-2016 I changed the library as suggested and etc. PHP Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); The library still do not work. Help me, I can not continue create the application RE: Extend Form_Validation - Tpojka - 04-04-2016 You don't need to create separate variable for CI instance if you are extending CI system class. Socondly, when loading your newly created class, you don't need prefix 'MY_'. PHP Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Controller example code: PHP Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); RE: Extend Form_Validation - lucavalentino - 04-05-2016 I try but not work. I am using Codeigniter 3.0.6 (last version) (04-04-2016, 03:32 PM)Tpojka Wrote: I believe that the controller does not read extensive library, but only the message from the language file RE: Extend Form_Validation - Tpojka - 04-05-2016 What I showed you is basic example from docs. You should test most simplified example like one in docs and see what (and if) went wrong. I already linked that page/section before. RE: Extend Form_Validation - InsiteFX - 04-05-2016 PHP Code: $this->CI =& get_instance(); RE: Extend Form_Validation - lucavalentino - 04-05-2016 (04-05-2016, 05:52 AM)InsiteFX Wrote: I try : PHP Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Now to continue the application I using callback function. RE: Extend Form_Validation - InsiteFX - 04-05-2016 PHP Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |