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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:35:02+00:00 2026-06-14T21:35:02+00:00

I need to set form validation rules in codeigniter from an AJAX call The

  • 0

I need to set form validation rules in codeigniter from an AJAX call
The call generates a $_POST array where i nest data from different forms (1:N) and then I set validation rules in this way:

$this->form_validation->set_rules($field, $label , $rules);

and the $_POST array will be similar at this:

field1: value1
field2: value2
field3: value3
field4: value4
field5: value5
field6: value6      
id: 86
operation: "add"

clearly, some forms may have colliding names, and this solution is not reliable.

For example

field1:value1
field1:value2

names are given dinamically, so i can’t afford to change them.

I choose to nest values in $_POST array:

form: 
    form1: 
           field1: value1
           field2: value2
    form2: 
           field1: value3
           field2: value4
    form3: 
           field1: value5
           field2: value6
id: 86
operation: "add"

but now form_validation is broken.

    $this->form_validation->set_rules('form[form1['.fieldN .']', $label   , $rules);

does not work as expected: i cannot validate. Looking into Form_validation.php library, set_rules first paramer is a string, and its value can be an array, but i can’t go deeper with nesting e.g. array of array.
There is a way to do this?Any hints?

  • 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-14T21:35:03+00:00Added an answer on June 14, 2026 at 9:35 pm

    You can pass array as a field name like this

    $this->form_validation->set_rules('options[]', 'Options', 'required');
    

    refer a details documentation for using array in Codeigniter’s validation class.

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

Sidebar

Related Questions

I'm new to working with Codeigniter and need to set a form validation rule
I need to set the value of a field in a form via JavaScript.
I'm building a desktop (thick) Infopath 2010 form with code-behinds that need to set
I need set a cultureinfo different of others in a currency field. Metadata: [Display(ResourceType
I am using the jQuery validation plugin on my form. I set the basic
With the new version of CodeIgniter; you can only set rules in a static
I need to create a form with the same group of fields (data is
I have a username textbox on a form, that has a few validation rules
Possible Duplicate: empty field validation in jquery I need to detect if a form
i'm trying to setup a codeigniter form with different error messages. set_message(rule, msg) is

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.