php - codeigniter validation not working in bootsrap modal window -
i trying validation class working in codeigniter within bootstrap modal window. function in controller contains codes not being seen form-open function.
this modal form:
<div class="modal fade" id="login" tabindex="-1" aria-labelledby="modallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h4 class="modal-title" id="mymodallabel">login</h4> </div> <div class="modal-body"> <?php echo validation_errors();?> <?php echo form_open('site/login_validation');?> <form> <div class="input-group"> <span class="input-group-addon"></span> <input type="text" name="email" class="form-control" placeholder="email"> </div></br> <div class="input-group"> <span class="input-group-addon"></span> <input type="text" name="password" class="form-control" placeholder="password"> </div></br> <button type="button" class="btn btn-default" data-dismiss="modal">close</button> <button type="submit" value="login" class="btn btn-primary">login</button> </br> </form> <?php echo form_close();?> <div class="modal-footer"> <a href="#" >forgot password</a> </div> </div> </div> </div> </div>
this form in controller:
public function login_validation(){ $this->load->helper(array('form','url')); $this->load->library('form_validation'); $this->form_validation->set_rules('email','','required'); $this->form_validation->set_rules('password','','required'); if ($this->form_validation->run() == false){ $this->load->view('view_index'); }else { redirect('site/view_member'); } }
as jcorry pointed out, you're duplicating <form>
, </form>
tags. if you're using form_open()
, form_close()
, don't need include them in view html.
from codeigniter docs:
form_open() creates opening form tag base url built config preferences
form_close() produces closing tag.
i suspect incorrect nesting confusing browser, trying close tags itself. if view source might see like:
<form action="site/login_validation"> </form><!-- closing tag added automatically browser --> <form> <!-- form fields ... --> </form> </form>
the second <form>
element, contains fields, has no action, isn't talking controller when hit submit. delete <form>
, </form>
in html , let know how goes.
Comments
Post a Comment