1

I am working on insert data using codeigniter. Here is the post data array which i get.

Problem: I am sending the app_soft_ids, lang_ids, working_days form my HTML form and so i get that in post as shown in post array here. But codeigniter didn't validate this three values.

How do i validate this three value? codeigniter Shows this Error after validation. I didn't get that how is it possible that i am sending data properly but CI validation still didn't get it.

The Application IDs field is required.

The Langusge IDs field is required.

The Working Days field is required.

Here is my post array.

Array
(
    [app_soft_ids] => Array
        (
            [0] => 66
            [1] => 68
        )

    [lang_ids] => Array
        (
            [0] => 4
            [1] => 5
        )
    [working_days] => Array
        (
            [0] => 4
        )

    [shift] => Y    
    [status] => O
    [expiry_date] => 10/07/2017
)

This is my validation code:

$config = array(
    'app_validation' => array(
        array(
                'field' => 'app_soft_ids',
                'label' => 'Application IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'lang_ids',
                'label' => 'Langusge IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'working_days',
                'label' => 'Working Days',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'shift',
                'label' => 'Shift',
                'rules' => 'required|trim|max_length[1]|'
        )
    )
);
2

1 Answer 1

0

Thanks to kumar_v comment I have get the way to validate the array is just add the [] init.

$config = array(
    'app_validation' => array(
        array(
                'field' => 'app_soft_ids[]',
                'label' => 'Application IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'lang_ids[]',
                'label' => 'Langusge IDs',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'working_days[]',
                'label' => 'Working Days',
                'rules' => 'required|numeric'
        ),
        array(
                'field' => 'shift',
                'label' => 'Shift',
                'rules' => 'required|trim|max_length[1]|'
        )
    )
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.