Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set error message for each field in codeigniter php

i want to set different error message for each field in the form.This is my controller..

$this->form_validation->set_rules('fname', 'First Name','required');
$this->form_validation->set_message('required', 'कृपया प्रथम नाव भरा','fname'); 
$this->form_validation->set_rules('address', 'Address','required');
$this->form_validation->set_message('required', 'कृपया पत्ता भरा','address');

but problem is that if validation fails it print only error message for last field.

like image 645
Kedar B Avatar asked Feb 02 '14 09:02

Kedar B


1 Answers

I solved it ...first of all autoload form helper and thern in view file

 <?php if (form_error('gender'))
 {
    echo "कृपया लिंग निवडा";
 } 
 ;?>

where 'gender' is my field name.And I do it for each field in my form.

like image 121
Kedar B Avatar answered Oct 15 '22 08:10

Kedar B