Reputation: 111
I'm using codeigniter form_validation, but it won't show any validation_errors message, this is my input tag named "name", I have already echo'd the validation_errors
<?= validation_errors(); ?>
<form action="" method="">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name">
</div>
this is my method to check if form_validation is correct
public function Add() {
$data['title'] = 'Add Student Form';
$this->form_validation->set_rules('name', 'Name', 'required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('templates/header', $data);
$this->load->view('student/add');
$this->load->view('templates/footer');
} else {
echo 'ok';
}
}
Why do I get no validation_errors message?
Upvotes: 3
Views: 54
Reputation: 844
The problem is you didn't specify what kind of method you are going to use. is it POST or GET ?.
In your case use the method POST
<form action="" method="POST">
Hope that helps :)
Upvotes: 2
Reputation: 83
Your Input Type name is as per you mentioned in the form validation set rules .. also you have printed validation_errors() .
<input type="text" class="form-control" id="name" name="nama">
to
<input type="text" class="form-control" id="name" name="name">
Upvotes: 0