Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Codeigniter PHP Controller Form Validation Error

    Hi I am just trying to work out how to get my php controller for codeigniter to show its Validation Error per input rather than all in one section.

    At the moment displays like this.

    Code:
    The Name field is required.
    
    The Email field is required.
    
    The Website field is required.
    
    The Subject field is required.
    
    The Message field is required
    
    <input class="form-control" name="name" value="" placeholder="">
    I am trying to get it so displays like this

    Code:
    <input class="form-control" name="name" value="" placeholder="">
    The Name field is required.
    <input class="form-control" name="name" value="" placeholder="">
    The Email field is required.
    and so on.

    I have to put this <?php echo validation_errors(''); ?> on top of the div in view page but just show all errors in that section which don't want

    Any ideas how to get it per line in codeigniter

    Code:
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Contactus extends MX_Controller {
    
    	public function index() {
    
    		$this->load->library('form_validation');
    
    		$this->form_validation->set_rules('name', 'Name', 'required');
    		$this->form_validation->set_rules('email', 'Email', 'required');
    		$this->form_validation->set_rules('website', 'Website', 'required');
    		$this->form_validation->set_rules('subject', 'Subject', 'required');
    		$this->form_validation->set_rules('message', 'Message', 'required');
    
    
    		if($this->form_validation->run() == FALSE)
    		{
    			$this->load->view('header');
    			$this->load->view('contactus');
    			$this->load->view('footer');
    		}
    		else
    		{
    			$this->load->view('header');
    			$this->load->view('confirmation');
    			$this->load->view('footer');
    		}
    
    	}
    }
    Founder Of Riwaka Website Designs
    http://www.riwakawebsitedesigns.com

  • #2
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts

    [Solved By Me]

    No body replied but I figured it out by my self me.
    Founder Of Riwaka Website Designs
    http://www.riwakawebsitedesigns.com

  • #3
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,872
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Could you post your solution? I'm sure others with the same desire would like to know how it's done.

  • #4
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by FishMonger View Post
    Could you post your solution? I'm sure others with the same desire would like to know how it's done.
    I have posted the solution on snippet section
    Founder Of Riwaka Website Designs
    http://www.riwakawebsitedesigns.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •