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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:59:55+00:00 2026-05-25T20:59:55+00:00

I have a controle to handle some information that can be either saved or

  • 0

I have a controle to handle some information that can be either saved or updated on DB.

I’m using public $validation to store an array with the validation rules that would look like this:

public $validation = array(
    array(
        'field' => 'modelname[column1]',
        'label' => 'Column 1',
        'rules' => 'required'
    ),
    array(
        'field' => 'modelname[column1]',
        'label' => 'Column 2',
        'rules' => 'required'
    ),

);

and I’m using my own validation function with callbacks in this same $validation. Like this:

array(
        'field' => 'modelname[column3]',
        'label' => 'Column 3',
        'rules' => 'callback_column3|required'
    ),
    array(
        'field' => 'modelname[column4]',
        'label' => 'Column4',
        'rules' => 'callback_column4|required'
    ),

Which is handled with an action in the Controller.
The problem is that:

For add ( save ) I have to check the uniqueness of the value, that’s the function of the callback_column4 ( let’s say ) and if it’s not unique it returns false. But, I can’t return false for the edit (update) because I’m reading and editing something that’s, obviously, in the DB.

So, what should I do to distinguish the two different action when validating.

PS: I have already tried to use subarrays with the Class/action ( http://codeigniter.com/user_guide/libraries/form_validation.html#savingtoconfig ) name but I’m using a Core_Model abstraction that plays the role of calling

$this->form_validation->set_rules($this->validation);
$this->form_validation->run()

  • 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-25T20:59:56+00:00Added an answer on May 25, 2026 at 8:59 pm

    You could add validation rules for that input in the controller method that is calling it rather than trying to put everything in the same array. That way you can keep your public validation var for all of the other rules but just set the one that is causing issues for you independently.

    You could also create two separate arrays for your validation rules and call each one for its respective method. i.e.

    $this->form_validation->set_rules($this->create_validation);
    

    and

    $this->form_validation->set_rules($this->edit_validation);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

WPF controls have certain properties (UserControl.Resources, UserControl.CommandBindings) that can have items added to them
I have some kind of reader which only has a handle (FILE*) to a
I have a .net web service that takes some xml data. From within the
I have a WPF window for editing database information, which is represented using an
I have a control that handles commenting. In this control, I have set a
I have control, subclassed from CDialogBar, it has some buttons(like on toolbar). When I
In WinForms, you have Control.BeginInvoke() , which means you can marshall a call from
I want to read UTF-8 strings from a server that I have control of,
I have a control that look something like this: <asp:DetailsView ID=dvUsers runat=server DataSourceID=odsData DataKeyNames=Id>
As a workaround for the fact that asp:Checkboxes don't have values, I am attempting

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.