そのため、CIの組み込みのform_validation「ツール」を初めて使用して、それを把握できないように研究しています。ビューのセットアップにすべてが正しく設定されており、コントローラーが正しくオンになっているようです...私の問題は、「送信」ボタンをクリックすると新しい関数にリンクされますが、入力した内容に関係なくエラーメッセージが表示されないことです「名前」、「メール」ボックス。検証を実行してエラーメッセージを表示するために必要なだけです。
コントローラーファイル
public function intelli()
{
$data["messages"] = "";
$this->load->view('engage_header');
$this->load->view('engage_nav');
$this->load->view('intelli/content_intelli', $data);
$this->load->view('engage_footer');
}
public function intelli_email()
{
$this->load->helper('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('name_area', 'Name', 'required|alpha|xss_clean');
$this->form_validation->set_rules('email_area', 'Email', 'required|valid_email|xss_clean');
$this->form_validation->set_rules('phone_area', 'Phone', 'is_numeric|xss_clean');
if ($this->form_validation->run() == FALSE) {
$data["messages"] = "";
} else {
$data["messages"] = "The Email has successfully been sent";
}
$this->load->view('engage_header');
$this->load->view('engage_nav');
$this->load->view('intelli/content_intelli', $data);
$this->load->view('engage_footer');
}
ファイルを閲覧する
<?php
$this->load->helper("form");
?>
<div class="request_demo">
<div id="request_logo"></div>
<div id="top_paragraph">
Intelliship & HALO deliver immediate and quantifiable ROI. Schedule a demo to learn how this transportation management software will positively impact your company's bottom-line profit.
</div>
<div id="entry_box">
<?php echo validation_errors();
echo $messages;
?>
<div id="request_form">
<?php echo form_open('/index.php/site/intelli_email')?>
<input id="name_area" type="text" placeholder="NAME" value="" required/><br/>
<input id="email_area" type="text" placeholder="EMAIL" value="" required/><br/>
<input id="phone_area" type="text" placeholder="PHONE" value=""><br/>
<input id="submit_req" type="submit" value="SUBMIT">
</form>
</div>
</div>
今のコードがずさんであることはわかっていますが、美しさよりも機能性を求めているだけです。また、ヘルパー(「フォーム」)をコントローラー内にロードしているため、ビューにロードするのは冗長です。