Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6893695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:41:27+00:00 2026-05-27T06:41:27+00:00

I am using the Codeigniter template library created by phil sturgeon (http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/). All works

  • 0

I am using the Codeigniter template library created by phil sturgeon (http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/).

All works correctly until I add form validation to my forms, I can’t seem to display the validation error messages how I did previously without the template library.

My validation is setup like:

        $data['page'] = $this->Content_model->getContent($page);//Get data from table "content" where "page" equals $page 

        $subnav_data['subnav'] = $this->Content_model->getSubnav($category);//Get sub navigation items from database
        $subnav_data['subnav_active'] = $page; //Set active subnav page

       $left_column = $this->load->view('widgets/sub_navigation', $subnav_data, true);
        $left_column .= $this->load->view('widgets/search_box', '', true); //Set data to be loaded into columns
        $left_column_base = $this->load->view('widgets/assist_navigation', '', true);
        $center_column = $this->load->view('content/text', $data, true); //Loads content from db in text view

//insert form into the template         
$center_column .= $this->load->view('forms/question', '', true);//Load form

        $center_column .= $this->load->view('widgets/breadcrumbs', '', true);
        $center_column .= $this->load->view('widgets/share', '', true);
        $right_column = $this->load->view('widgets/ask_us_a_question', '', true);
        $right_column .= $this->load->view('widgets/newsletter', '', true);
        $right_column .= $this->load->view('widgets/latest_news', '', true);

        $this->template->inject_partial('left_column', $left_column); //Inject data into the partial columns
        $this->template->inject_partial('left_column_base', $left_column_base);
        $this->template->inject_partial('center_column', $center_column);
        $this->template->inject_partial('right_column', $right_column);

$this->load->library('form_validation');//Load form validation
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
$this->form_validation->set_rules('first_name', '"First name"', 'trim|required|alpha_dash|min_length[3]|max_length[55]');
$this->form_validation->set_rules('last_name', '"Last name"', 'trim|required|alpha_dash|min_length[3]|max_length[55]');
$this->form_validation->set_rules('service', '"Service"', 'trim|required|alpha_dash|min_length[3]|max_length[55]');
$this->form_validation->set_rules('email_address', '"Email address"', 'trim|required|valid_email');
$this->form_validation->set_rules('phone_number', '"Phone number"', 'trim|numeric|min_length[8]|max_length[20]');
$this->form_validation->set_rules('question', '"Question"', 'trim|required|min_length[20]|max_length[500]');

if ($this->form_validation->run() == FALSE){
    $this->template->build('template',$data); 
}
else
{       

  if($this->Question_model->submit_question()){        
    $this->session->set_flashdata('success', 'success');
    redirect('question', 'location');                           
  }
  else{
    $this->template->build('template',$data); 
  }

}

This is my form where I intend to display the validation errors:

<div id="form">
<?php 
    echo '<div id="error_container">' . validation_errors() . '</div>';

    echo form_open('question');

    //First name
    echo '<b>'.form_label('First name *', 'first_name').'</b>';
    echo form_input('first_name',set_value('first_name'));

    //Last name
    echo '<b>'.form_label('Last name *', 'last_name').'</b>';
    echo form_input('last_name',set_value('last_name'));    

    //Email address
    echo '<b>'.form_label('Email address *', 'email_address').'</b>';
    echo form_input('email_address',set_value('email_address'));    

    //Phone number
    echo '<b>'.form_label('Phone number *', 'phone_number').'</b>';
    echo form_input('phone_number',set_value('phone_number'));  

    //Service
    echo '<b>'.form_label('Service *', 'service').'</b>';
    echo '<select name="service">';
    echo'<option value=""'.set_select('service', TRUE).' >Select a service...</option> ';
    echo'<option value="investments"'.set_select('service', 'investments').' >Investments</option> ';
    echo'<option value="mortgages"'.set_select('service', 'mortgages').' >Mortgages</option> ';
    echo'<option value="other"'.set_select('service', 'other').' >Other</option> ';
    echo '</select>';

    //Question
    echo '<b>'.form_label('Question *', 'question').'</b>';
    echo form_textarea('question',set_value('question'));

    echo '<p><i>Your question will be forwarded to our consultants who will answer and return their response in the fastest time possible.</i></p>';

    echo form_submit('submit', 'Ask question');

    echo form_close();
?>
</div>

Upon submit the validation errors should be displayed, but aren’t. The validation is successfully stopping the form posting when errors are found, but is not showing the errors to the user.

Is there something else required for form validation to work with the template library, how can I debug the issue???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:41:28+00:00Added an answer on May 27, 2026 at 6:41 am

    Is there something else required for form validation to work with the template library

    Well, yes, you need to echo the form error out, e.g.

    //First name
    echo '<b>'.form_label('First name *', 'first_name').'</b>';
    echo form_input('first_name',set_value('first_name'));
    
    echo form_error('first_name');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all im using this template system http://williamsconcepts.com/ci/codeigniter/libraries/template/index.html but now i want to add
I am using Codeigniter 1.7.2 and Phil Sturgeon's wonderful Dwoo wrapper which allows me
I'm using CodeIgniter, and will likely use their template library as I want to
I'm using CodeIgniter and I got a model that fetches let's say all recipes
I am using codeigniter and its pagination class. It works perfectly and it looks
I am using codeigniter. My products page shows all the products we have and
I'm using CodeIgniter (v1.7.2) and I've created a custom controller that incorporates authentication called
I am uploading a PDF using the codeigniter upload library, the PDF is uploaded
I have made a site with codeigniter and am using the googlemaps v3 library
I am using CodeIgniter to pass some parameters to my PHP page through $_POST

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.