1

I have view page, with ng-repeat. I have a field with an array type, I have tried field name by keeping nursing_array and nursing_array[] but both are not working in Codeigniter validation. Below is my code what mistake I am doing such type of things I have done hundreds of times but not able to find this time what wrong I am doing.

View Page,

<div class="col-md-6"  ng-repeat ="nurs in nursing" ng-if="nurs.id" >
        <input type="checkbox"  id="{{nurs.id}}" name="nursing_array"  ng-model="PostJobData.nursing_array[nurs.id]" value="{{nurs.id}}">
        <label for="{{nurs.id}}">{{nurs.name}}</label>
</div>

Controller

$this->form_validation->set_rules('nursing_array[]', 'Nursing', 'required');

1 Answer 1

1

Hey Please check the syntax of set_rule

You are passing nursing_array but validating nursing_array[]

Please change nursing_array[] to nursing_array

Working Example

$this->form_validation->set_rules('nursing_array[]', 'Nursing', 'required');

To

$this->form_validation->set_rules('nursing_array', 'Nursing', 'required');

Note : This form validation library works only post data ,For more information please refer official documentation https://www.codeigniter.com/userguide3/libraries/form_validation.html

Sign up to request clarification or add additional context in comments.

1 Comment

Hey anand jain , please change your if condition like this if ($this->form_validation->run($this) === FALSE) , still not working please update your code...

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.