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 7982509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:41:49+00:00 2026-06-04T10:41:49+00:00

Im carrying out some form validation with codeigniter using a custom validation callback. $this->form_validation->set_rules(‘testPost’,

  • 0

Im carrying out some form validation with codeigniter using a custom validation callback.

$this->form_validation->set_rules('testPost', 'test', 'callback_myTest');

The callback runs in a model and works as expected if the return value is TRUE or FALSE. However the docs also say you can return a string of your choice.

For example if I have a date which is validated, but then in the same function the format of the date is changed how would I return and retrieve this new formatted value back in my controller?

Thanks for reading and appreiate the help.

  • 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-06-04T10:41:50+00:00Added an answer on June 4, 2026 at 10:41 am

    I’m not entirely sure I got what you were asking, but here’s an attempt.

    You could define a function within the constructor that serves as the callback, and from within that function use your model. Something like this:

        <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Controllername extends CI_Controller {
    
       private $processedValue;
    
       public function index()
       {
            $this->form_validation->set_rules('testpost','test','callback');
    
            if ($this->form_validation->run()) {
             //validation successful
             echo $this->processedValue; //outputs the value returned by the model
            } else {
             //validation failed
            }
       }
    
       private function callback($input)
       {
            $this->load->model('yourmodel');
            $return = $this->yourmodel->doStuff($input);
    
            //now you have the user's input in $input
            // and the returned value in $return
    
            //do some checks and return true/false
    
            $this->processedValue = $return;
       }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm carrying out some experiments in theorem proving with combinator logic, which is looking
I am carrying out a number of calculations using NSDecimal and am creating each
I am just carrying out a query, and have started using parameters. And all
I have this API - which I managed to carryout some API steps solely
How would you model a system that handles permissions for carrying out certain actions
I am currently carrying out research for the design and implementation of a web-based
I am a student carrying out a study to enhance a search engine's existing
I have been carrying out 2D and 3D operations, including graphics, for many years
The first operation will be carrying out several calculations and updating the same tables
I have just recently started carrying out unit testing for my software written in

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.