Form submit not working in mobile chrome

edited October 2012 in Feature Requests
I have a form which is working fine on desktop browsers, but on mobile browser (chrome on android) it just refresh page after submitted, and I tried to use type='submit' & type='button' & js to handle the submit action but all failed. The form is almost same as contact page included in 0.93 package, it email to admin after submitted. Would you let me know some solutions? Thanks.

Comments

  • edited 6:03AM
    Do you have a link or some code? Can't replicate with any of my forms.
  • edited October 2012
    http://keeplearning.hk/site/#!info

    controller:
    <?php
    class Info extends CI_Controller {

    function __construct()
    {
    parent::__construct();
    }

    function index()
    {
    $this->load->library('session');
    $this->load->library('form_builder');

    if (!empty($_POST) AND $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR'])
    {
    // put your processing code here... we show what we do for emailing. You will need to add a correct email address
    if ($this->_process($_POST))
    {
    $this->session->set_flashdata('success', TRUE);
    //redirect('info');
    }
    }

    $fields = array();
    $fields['name'] = array('required' => TRUE);
    $fields['tel'] = array('required' => FALSE);
    $fields['email'] = array('required' => TRUE);
    $fields['message'] = array('required' => TRUE, 'type' => 'textarea');

    $this->form_builder->set_fields($fields);

    // will set the values of the fields if there is an error... must be after set_fields
    $this->form_builder->set_validator($this->validator);
    $this->form_builder->set_field_values($_POST);
    $this->form_builder->display_errors = TRUE;
    $this->form_builder->required_text = '*required fields';
    $this->form_builder->form_attrs = array('method' => 'post', 'action' => 'info');
    $vars['form'] = $this->form_builder->render();

    // use Fuel_page to render so it will grab all opt-in variables and do any necessary parsing
    $page_init = array('location' => 'info');
    $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init);
    $this->fuel_page->add_variables($vars);
    $this->fuel_page->render();
    }

    function _process($data)
    {
    $this->load->library('validator');
    /*
    Set rules up here so we can pass them to the form_builder to display errors.
    validator_helper contains the valid_email function... validator helper automatically gets' looded with Validation Class'
    */

    $this->validator->add_rule('name', 'required', 'Please enter in an first name', $this->input->post('name'));
    //$this->validator->add_rule('last_name', 'required', 'Please enter in an last name', $this->input->post('last_name'));
    $this->validator->add_rule('email', 'valid_email', 'Please enter in a valid email', $this->input->post('email'));
    $this->validator->add_rule('message', 'required', 'Please enter in an message', $this->input->post('message'));


    if ($this->validator->validate())
    {
    $config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => '********',
    'smtp_pass' => '********',
    'mailtype' => 'html',
    'charset' => 'UTF-8',
    'wordwrap' => true
    );
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");
    $this->load->helper('inflector');

    // send email
    $this->email->from($data['email'], $data['name']);

    /*********************************************************************
    YOU MUST FILL OUT THE CORRECT dev_email config in application/config/MY_config.php
    AND/OR THE CORRECT TO email address
    *********************************************************************/
    // check config if we are in dev mode
    if ($this->config->item('dev_mode'))
    {
    //echo $this->config->item('dev_email');
    $this->email->to($this->config->item('dev_email'));
    }
    else
    {
    // need to fill this out to work
    $this->email->to('********');
    }
    $this->email->subject('Website Contact Form');
    $msg = "FROM KEEPLEARNING:

    ";
    foreach($data as $key => $val)
    {
    $msg .= humanize($key, 3).":
    ".$val."

    ";
    }
    $this->email->message($msg);

    // let her rip
    if (!$this->email->send())
    {
    add_error('There was an error notifying');
    return FALSE;
    }

    return TRUE;
    }

    }
    }

    Thanks!
  • edited 6:03AM
    Another question, now my site was installed in a subfolder, and I just wanna access it with xxx.com directly but not xxx.com/site/, is it possible to do this, maybe using .htaccess in root and disable the one inside project folder? Or how? Thanks again.
  • edited 6:03AM
    Try removing from the if condition on POST:
    $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR']

    I don't think your suggestion to change the .htaccess that way will work because of how CI figures out the URI path. Do you have access to your apache configuration? If so, you can set that folder as the document root.
  • edited 6:03AM
    It works after remove that, thanks very much.

    Another problem, assume that I have permission to modify the apache configuration, and I changed DocumentRoot, then yes can access site with only root path, however, in fact, my home view is a blank page which is used for ajax only, it just like a template. After loaded, I check hash or pathname and load the content and insert by js, and now it can't load any content, just keep blank, the problem is the url of other page, e.g. localhost/home or localhost/#!home, are getting 500 return, I have no idea how to do..
  • edited 6:03AM
    Is it perhaps localhost is the same as localhost/home with FUEL?
Sign In or Register to comment.