На странице несколько полей с разными именами, по умолчанию - по одному:
<input type="text" name="name[]">
Данные сериализуются и передаются AJAX'ом. На стороне PHP принимаю так:
parse_str($_POST['data'], $params);
// POST PARENT
$_POST['name[]'] = $params['name'];
$_POST['lastname[]'] = $params['lastname'];
Далее валидация CI:
$this->form_validation->set_rules('name[]', 'Parent name', 'required|xss_clean|htmlspecialchars|min_length[2]|max_length[10]|alpha');
При валидации получаю ошибку:
<p>Severity: Warning</p>
<p>Message: preg_match() expects parameter 2 to be string, array given</p>
<p>Filename: libraries/Form_validation.php</p>
<p>Line Number: 1172</p>
Из ошибки ясно, что летит на обработку массив, а не строка...Но раньше при поступлении массива name, и задания правила name[] - все работало прекрасно...
Полный код валидации:
// PARENT VALIDATION
$this->form_validation->set_rules('name[]', 'Parent name', 'required|xss_clean|htmlspecialchars|min_length[2]|max_length[10]|alpha');
$this->form_validation->set_rules('lastname[]', 'Parent secondname', 'required|xss_clean|htmlspecialchars|min_length[2]|max_length[14]|alpha');
$this->form_validation->set_rules('status[]', 'Status', 'required|integer');
$this->form_validation->set_rules('area[]', 'Sector', 'required|integer');
$this->form_validation->set_rules('street[]', 'Street', 'required|xss_clean|htmlspecialchars|min_length[3]|max_length[20]');
$this->form_validation->set_rules('block[]', 'Block', 'required|numeric');
$this->form_validation->set_rules('mobile[]', 'Mobile', 'required|min_length[8]|man_length[9]|numeric');
$this->form_validation->set_rules('phone[]', 'Phone', 'required|min_length[8]|max_length[9]|numeric');
$this->form_validation->set_rules('email[]', 'Return email', 'xss_clean|valid_email');
$this->form_validation->set_rules('apart[]', 'Apartament', 'numeric');
// CHILDREN VALIDATION
$this->form_validation->set_error_delimiters('<li>', '</li>');
$this->form_validation->set_rules('nameChild', 'Child name', 'required|trim|xss_clean|htmlspecialchars|min_length[2]|max_length[10]|alpha');
$this->form_validation->set_rules('lastnameChild', 'Child secondname', 'required|trim|xss_clean|htmlspecialchars|min_length[2]|max_length[14]|alpha');
$this->form_validation->set_rules('kindergartner', 'Gradinita', 'required|integer');
$this->form_validation->set_rules('streetChild', 'Child Street', 'required|trim|xss_clean|htmlspecialchars|min_length[3]|max_length[20]');
$this->form_validation->set_rules('area', 'Area', 'required|integer');
$this->form_validation->set_rules('sex', 'Sex', 'required|integer');
$this->form_validation->set_rules('limba', 'Limba', 'required|integer');
$this->form_validation->set_rules('idnp', 'IDNP', 'required|trim|min_length[13]|max_length[13]|numeric');
$this->form_validation->set_rules('captcha', 'Code', 'trim|required|exact_length[5]|alpha|callback__captcha_check');