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 -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -