How can i validate fields with names like this
<select name="mechanic_134" id="mechanic-134" class="form-control selectpicker">
mechanic_ is the general field name & 134 is a id i am getting from database. there are more fields to come like mechanic_135........mechanic_150.
i want to know how can i validate this field with dynamic id. please show it in code level. how it is done in controller & how the error output in view
Have a look (view)
http://www.screencast.com/t/jhXvVBUH
i have tried this in my controller but i don't know how to show this in view (the error message)
foreach ($this->input->post() as $key=>$value) {
if (! strpos('mechanic_',$key) === FALSE ) {
$this->form_validation->set_rules($key, 'Mechanic', 'trim|required');
}
}
Thanks.