Welcome Guest, Not a member yet? Register   Sign In
Really need help, How to get error message from "form_validation" ?
#1

[eluser]dimasVS[/eluser]
Hi all,,
I really need your help,
How to get the error message from "form_validation", cause I want to throw that error message into another file,

For example, I didn't fill editorID field, how to get error message "The Editor ID field is required" in controller directory.

This is my code in controllers :

Code:
function addEditor(){
            $this->form_validation->set_rules('editorID', 'Editor ID', 'trim|required|min_length[5]|xss_clean');
            $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[2]');
            $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
            $this->form_validation->set_rules('nama', 'Nama', 'trim|required|min_length[5]|xss_clean');
            $this->form_validation->set_rules('tgl_lahir', 'Tanggal Lahir', 'trim|required');
            $this->form_validation->set_rules('pekerjaan', 'Pekerjaan', 'trim|required|min_length[1]|xss_clean');
            $this->form_validation->set_rules('sex', 'Sex', 'trim|required|min_length[4]|xss_clean');
            $this->form_validation->set_rules('alamat', 'Alamat', 'trim|required|xss_clean');
            if ($this->form_validation->run() == FALSE){
                $this->load->view('getconf/administrator_addEditor');
            }else{
                echo "Berhasil";
            }
        }

Thank you so much...
Best Regards,
#2

[eluser]VernonK[/eluser]
Code:
$validation_errors = (validation_errors()) ? validation_errors() : false;

//or

if(validation_errors()) {
$validation_errors = validation_errors();
} else {
$validation_errors = false;
}
#3

[eluser]VernonK[/eluser]
Something I should have mentioned in my original reply was that you can put the validation_errors() function in your view.

&lt;?php echo validation_errors('<p>', '</p>'); ?&gt;

You can put that right at the top of the form. The paragraph tags are areas that you can set what the errors are wrapped in.
#4

[eluser]dimasVS[/eluser]
[quote author="VernonK" date="1271534040"]Something I should have mentioned in my original reply was that you can put the validation_errors() function in your view.

&lt;?php echo validation_errors('<p>', '</p>'); ?&gt;

You can put that right at the top of the form. The paragraph tags are areas that you can set what the errors are wrapped in.[/quote]

Hi VernonK,
Thank you very much for your response,

I was waiting so long, and I got the way to solve like your last answer. Smile
#5

[eluser]Bart v B[/eluser]
I think that's very well explained in the userguide Wink
http://ellislab.com/codeigniter/user-gui...tingerrors

Just scroll a little lower, and there is also explaind that they can be sepperated. Wink
#6

[eluser]dimasVS[/eluser]
[quote author="Bart v B" date="1271965042"]I think that's very well explained in the userguide Wink
http://ellislab.com/codeigniter/user-gui...tingerrors

Just scroll a little lower, and there is also explaind that they can be sepperated. Wink[/quote]

LOL...
you're right,
but sometimes I didn't know the meaning of that word in Indonesian.. Smile




Theme © iAndrew 2016 - Forum software by © MyBB