This is a quick demo of javascript portion:
var student = {};
student['name'] = 'ABC';
student['dob'] = '1-1-2015';
student['address'] = {};
student['address']['home'] = 'somewhere on earth';
student['address']['office'] = 'near mars';
student['contactnum'] = {};
student['contactnum']['home'] = {};
student['contactnum']['home']['mob'] = '12345';
student['contactnum']['home']['phone'] = '987';
student['contactnum']['office'] = {};
student['contactnum']['office']['mob'] = '12345';
student['contactnum']['office']['phone'] = '987';
$.ajax({
type: "POST",
url: "<?php echo base_url('admin/ajax/addStudent');?>",
data: {'d': JSON.stringify( student ) },
contentType: 'application/json'
})
As you can see am sending this associative array object to the CodeIgniter page via AJAX. But the question is, how to use the FormValidation helper at the server side! To my belief, the validation helper only checks for single field names. Since all the validations needed for me is in that helper, I don't want to reinvent the wheel, but want to know how to write validation config for this data at CodeIgniter page!