我正在使用 codeigniter form_validation,但它不会显示任何 validation_errors 消息,这是我名为“name”的输入标签,我已经回显了 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>
这是我检查 form_validation 是否正确的方法
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';
}
}
为什么我没有收到 validation_errors 消息?
最佳答案
问题是您没有指定要使用哪种方法。是 POST 还是 GET?
在你的情况下使用方法POST
<form action="" method="POST">
希望对您有所帮助:)
关于php - Codeigniter form_validations 不会显示任何 validation_errors 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57950843/