CodeIgniter Forums
auto fill a field from input box - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: auto fill a field from input box (/thread-49456.html)

Pages: 1 2


auto fill a field from input box - El Forum - 02-20-2012

[eluser]CroNiX[/eluser]
not without seeing the code where you are performing your validation.


auto fill a field from input box - El Forum - 02-21-2012

[eluser]the_unforgiven[/eluser]
Of course sorry i forgot about that lol

Code:
function send()
{
  $this->load->library('form_validation');
  // Set Validation Rules
  $this->form_validation->set_rules('name', 'Name', 'trim|required|min_length[3]');
  $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
  $this->form_validation->set_rules('phone', 'Phone', 'trim|required|max_length[12]');
  $this->form_validation->set_rules('message', 'Message', 'trim|required|min_length[2]');

   // You can set additional rules here, but keep CAPTCHA test
  $rules = array(                    
               array(
                  "field" => "recaptcha_challenge_field",
                  "label" => "reCAPTCHA",
                  "rules" => "required|recaptcha_matches"
                )
             );

  $this->form_validation->set_rules($rules);
  
  // Validation runs false rteun back to form and show errors
  if ($this->form_validation->run() == FALSE) {
  
   $data['title'] = 'Contact us ';
   $data['description'] = '';
   $data['keywords'] = '';
   $data['main_content'] = 'contact';
   $data['error'] = $this->session->set_flashdata('error', 'Sorry there where some errors');
         $this->load->view('template', $data);
  }
  // If everything is filled out with no errors procced with sending the form to email and database
  else {
  $name = $this->input->post('name');  
  $email = $this->input->post('email');
  
  $message = "Hey guys, someone has requested left a message" . "\n\r\n";
  $message .= "Name:". $this->input->post('name') . "\n";
  $message .= "Email:". $this->input->post('email') . "\n";
  $message .= "Phone:". $this->input->post('phone') . "\n";
  $message .= "Message:". $this->input->post('message');

  $this->email->from($email, $name);
  $this->email->to('[email protected]');
  $this->email->subject('req');
  $this->email->message($message);
  $this->email->send(); // Send the message function to the persons email address
  $this->email->clear(); // Clears the form ready for another submission

  $data['title'] = 'Thank you, Message received.';
  $data['description'] = '';
  $data['keywords'] = '';
  $data['main_content'] = 'thanks';
        $this->load->view('template', $data);

  }
}



auto fill a field from input box - El Forum - 02-21-2012

[eluser]CroNiX[/eluser]
I'd start with some basic troubleshooting. Like, commenting out your validation rules except the first one and running the form. If it passes, uncomment the next rule and repeat until you get the error. I'm betting it's your captcha rules. I don't see where you load the captcha helper and there is no recaptcha_matches validation rule that I am aware of. Although, I haven't used CI's captcha in a long time...


auto fill a field from input box - El Forum - 02-21-2012

[eluser]the_unforgiven[/eluser]
Yes i'll try that Chronix, and i seem to think its the captcha validation too,


auto fill a field from input box - El Forum - 02-21-2012

[eluser]the_unforgiven[/eluser]
If i comment out all the validation it works, soon as I put validation rules back in it show the error.

All helpers and lib files are autoloaded in the autoload.php config file btw


auto fill a field from input box - El Forum - 02-21-2012

[eluser]CroNiX[/eluser]
So if you only have 1 validation rule, like the "name" rule, it still fails?


auto fill a field from input box - El Forum - 02-21-2012

[eluser]the_unforgiven[/eluser]
Yes buddy, and not sure why!!! Sad


auto fill a field from input box - El Forum - 02-21-2012

[eluser]CroNiX[/eluser]
Sorry, If you commented out everywhere a rule is set except the first one and still get the error I'm not sure either (unless this is from within a library and not a controller). If you use a stepping debugger you could probably quickly find out though.


auto fill a field from input box - El Forum - 02-21-2012

[eluser]the_unforgiven[/eluser]
yes ill find it don't worry thanks again chronix legend