を示さないが私のコントローラコードです:ここでは私はCodeIgniterの中でプロジェクトを開発していますが、他のconditonのフォーム検証エラーがここで何らかのエラー
public function onlineordercheck()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('postcode', 'Postcode',
'required|trim|integer|max_length[4]',
array('integer' => 'We are sorry, currently we do not provide services in your area.',
'max_length[4]'=>'We are sorry, currently we do not provide services in your area.'));
$this->form_validation->set_error_delimiters("<div class='text-danger'>","</div>");
if($this->form_validation->run())
{
$postcode= $this->input->post('postcode');
$this->load->model('Common_m');
$check_code=$this->Common_m->check_pincode($postcode);
if($check_code)
{
//Credentials valid login user
$this->session->set_userdata('postcode',$check_code);
$this->load->view('template',array('page_title'=>'pageName','middle_view'=>'schedule_pickup'));
}
else
{
//authentication failed
$this->load->view('template',array('page_title'=>'pageName','middle_view'=>'online_order'));
$this->form_validation->set_message('postcode', 'Service for this postcode is not available.');
}
}
else
{
$this->load->view('template',array('page_title'=>'pageName','middle_view'=>'online_order'));
}
}
マイビューのページです:
<div class="container" style="margin:20px;">
<div class=" col-sm-12 row">
<div class="col-sm-12">
<div class="col-sm-12 thumbnail text-center">
<img alt="" class="img-responsive" src=`"<?php echo base_url(); ?>`images/imageName.jpg">
<div class="caption">
<?php echo form_open('COrders/onlineordercheck', [ 'class' => 'form-horizontal' ]); ?>
<div class="title">Postcode</div>
<?php echo form_input([ 'name' => 'postcode', 'placeholder' => 'Postcode' ]) ?>
<?php echo form_error('postcode'); ?>
<?php echo form_submit
([
'class' => 'btn btn-primary',
'type' => 'submit',
'value' => 'Check Times'
]) ?><?php echo form_close(); ?>
</div>
</div>
</div>
</div>
</div>
私は負荷form_helper
を持っていましたコンストラクタにバリデーションライブラリを作成します。 check_pincode($pincode)
メソッドが返る場合false
その時set_message
は動作しません...
set_message
に何が変わる予定ですか?