error encounter while including form_validation library |
Hi,
My self keyur joshi and i am new to codeignitor 3.0.6 and i god following error while submitting form (form_validation error) and my code is as follow here is my controller Vendor and i am trying to do the validation on vendor name while post the form plz. help me in this thanks in advance <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Vendors extends CI_Controller { function __construct() { parent::__construct(); //$this->output->enable_profiler(TRUE); $this->load->helper(array('form', 'url')); $this->load->model('VendorsModel'); $this->load->library('form_validation'); $config = array( array( 'field'=>'vname', 'label'=>'Vendor Name', 'rules'=>'required', 'errors' => array( 'required' => 'Please input %s', ), ), ); $this->form_validation->set_rules($config); } public function index() { $data['data_get'] = $this->VendorsModel->listvendors(); $this->load->view('header'); $this->load->view('sidebar-menu'); $this->load->view('vendorsview',$data); $this->load->view('footer'); } public function add() { $this->load->view('header'); $this->load->view('sidebar-menu'); $this->load->view('vendorsnew'); $this->load->view('footer'); } function save() { if ($this->input->post('mit')) { if ($this->form_validation->run() === FALSE) { $this->VendorsModel->add(); redirect('vendors'); } else { redirect('vendors/add'); } } else { redirect('vendors/add'); } } } thanks keyur joshi
First of all, when you share php code, please use the php button on the tool bar of the forum's editor window.
The best structure for handling forms with form validation is this: PHP Code: public function edit() In this case, your form view should have this line: PHP Code: echo form_open(); // form is posted to original url |
Welcome Guest, Not a member yet? Register Sign In |