php - Codeigniter: Include actual input value from validation error message -


good day!

fast newbie question.

i have validation controller:

$this->form_validation->set_rules("item_name", "item name", "trim|xss_clean|max_length[100]|required|is_unique[tbl_item.item_name]"); // update: suggested asad khan , nargis parween,  // changed this: // $this->form_validation->set_message("is_unique", "this %s exists."); // this: $this->form_validation->set_message("is_unique", "this {field} exists.");  // prints "this item code exists" when validation fails. 

question: how replace '%s' actual input value? result "item-01 exists."

thanks in advance guys!

you can append field value in message. try this:

$this->form_validation->set_message("is_unique", $this->input->post('item_name')." exists."); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -