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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:31:20+00:00 2026-05-26T21:31:20+00:00

I am not being able to run validation on an array of input fields.

  • 0

I am not being able to run validation on an array of input fields. When I submit the form, it is submitted OK (data is saved correctly), but without validation (no errors, no messages).

Any idea what I’m doing wrong?

My view:

<?php echo form_open('save', array('id' => 'form')); ?>
    <?php foreach ($cars as $row): ?>
        <table>
            <tr>
                <td>
                    <h2>
                        <?php echo $row->cars_name; ?>
                    </h2>
                </td>
                <th>
                    Number
                </th>
                <td>
                    <?php echo form_input("car[$row->cars_id][cars_number]", $row->cars_number); ?>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <th>
                    Registry
                </th>
                <td>
                    <?php echo form_input("car[$row->cars_id][cars_number_reg]", $row->cars_number_reg); ?>
                </td>
            </tr>
        </table>

    <?php endforeach; ?>
<?php echo form_close(); ?>

My config/form_validation.php:

'test/save' => array(
                array(
                        'field' => 'car[]', // also tried car[][], but no go
                        'label' => 'Field',
                        'rules' => 'alpha|htmlspecialchars|trim'
                     ),
                ),

My controller:

function save()
{
    if ($this->form_validation->run() == FALSE) {

        $json['success'] = '0';
        $json['message'] = validation_errors();
        echo json_encode($json);

    } else {

        $car = $this->input->post('car');

        foreach ($car as $k => $v) {

            $data['cars_number']       = $v['cars_number'];
            $data['cars_number_reg']   = $v['cars_number_reg'];

            $cars_id = $k;

            $this->emergency_model->save($data, $cars_id);
        }

        $json['success'] = '1';
        echo json_encode($json);
    }
}
  • 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-26T21:31:21+00:00Added an answer on May 26, 2026 at 9:31 pm

    I suggest using a callback validation function like in this tutorial
    in this tutorial

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

Sidebar

Related Questions

I am not being able to run Powermock through maven. I'm the PowerMock Mockito
I feel stupid for not being able to find this, but where is the
Why would Mono not being able to run under IIS 7 ? Update: what
Not being able to find the answer, and also not being able to do
I'm stuck at not being able to map texture to a square in openGLES.
I'm not being able to make this line work with Tk import os while(1):
So I've resigned myself to not being able to use the order of a
I'm getting an exception from Cruise Control about not being able to connect to
Is this possible? I had troubles with SVN clients not being able to access
System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(path)) So this is a work around to not being able to use T4

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.