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

angular - DownloadURL return null in below code -

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -