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

  • SEARCH
  • Home
  • 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 6323317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:29:39+00:00 2026-05-24T16:29:39+00:00

New to CodeIgniter and new to Ocular so bear with me. I used to

  • 0

New to CodeIgniter and new to Ocular so bear with me.

I used to code in the following way when running form validation (where the index() method contains the form loading code):

if ($this->form_validation->run() == FALSE)
{
    $this->index();
}
else
{
    $this->load->view('view_name', $data);
}

However I’m now trying to use the Ocular Template Library and the above code no longer works see example below:

if ($this->form_validation->run() == FALSE)
{
    $this->index();
}
else
{
    $this->template->set($data);
    $this->template->render();
}

The above code does not run through the index method as it used to without Ocular and I was wondering what the best practice is to correct this or even if my previous code was best practice?

Regards,
Numan1617

  • 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-24T16:29:41+00:00Added an answer on May 24, 2026 at 4:29 pm

    Sometimes it’s hard to determine best practice with Codeigniter because it’s convention-less nature, so all I can really tell you is how I’ve found best in my experience…

    I assume you’re form view is being served up via index() and then you’re submitting your form to this (seperate) controller function that validates and processes the form data, and re-displays the view with errors if there was a problem…

    I would clean this up by consolidating it all into a single function…

    public function form()
    {
        //if this is a post request
        if ($_POST)
        {
            //check the validation
            if ($this->form_validation->run())
            {
                //process it
                //and then redirect if you want to send to a "success" page
                redirect('uri/to/success');
            }
            else
            {
                //load up $data values to re-display form
            }
        }
    
        //load up any $data values needed for standard view
        $this->load->view('view', $data);
        // or $this->template stuff...
    
    }
    

    It always seemed to me to be a bad route to go down calling controller functions internally, ex. $this->index()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to CodeIgniter. I've been loading common templates like header and footer in
New to HMVC in Codeigniter. Dynamic form allows new segments to be created when
Im running CodeIgniter for a project of mine ... Im fairly new to this,
EDIT: I am using Code Igniter: www.codeigniter.com So I'm new to web developement and
I have some legacy code that needs to be used in a new application.
i am new to Codeigniter and I have some trouble in select box validation.
I'm new to CodeIgniter, and I need some help. I'd like to implement the
I'm new to codeigniter this is my case: I have a homepage with a
I'm still quite new to CodeIgniter and I was wondering, where should I place
I am developing a new project in CodeIgniter (CI), and would like to find

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.