Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(FUEL_PATH.'/libraries/Fuel_base_controller.php');
- error_reporting(-1);
- ini_set('display_errors', 1);
- class Testas extends CI_controller {
- public function __construct()
- {
- parent::__construct();
- }
- public function index()
- {
- $this->load->module_language('fuel', 'fuel');
- $this->load->library('form_builder');
- $this->load->library('validator');
- $fields['email'] = array('type' => 'email', 'label'=>'Email', 'required' => TRUE);
- $fields['name'] = array('type' => '','label'=>'Your name');
- $this->form_builder->set_fields($fields);
- $validator = $this->form_builder->get_validator();
- //var_dump($validator);exit; //If I uncomment it, it echoes NULL
- $validator->add_rule('name', 'required', "This is required", array($this->input->post('name')));
- if (!empty($_POST))
- {
- if ($validator->is_valid())
- {
- echo "validation succeeded";
- }
- else
- {
- echo "validation failed";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement