2

I'm trying to post my form by method="GET" instead of POST.

Codeigniter's form_validation->run() doesn't work.

It's not returning any form_error in view page.

Vickel
  • 7,879
  • 6
  • 35
  • 56
mathew
  • 86
  • 7

2 Answers2

2

If you have to use $_GET, you could set the validation data before the validation rules :

$this->form_validation->set_data($_GET);

See : Validating an Array (other than $_POST)

Community
  • 1
  • 1
Hasta Dhana
  • 4,699
  • 7
  • 17
  • 26
1

The concept of form_validation is based on the use POST, as the form validation function form_validation->run() builds its validation array with POST.

see Codeigniter public function run() at around line 417 of system/libraries/Form_validation.php:

$validation_array = empty($this->validation_data)
          ? $_POST
          : $this->validation_data;

but as pointed out in the answer of @Hasta Dhana, you can use $_GET or any other array like:

$this->form_validation->set_data($_GET);

if you want to validate an array that does not originate from $_POST data. This array takes then the place of $this->validation_data in the if clause

Vickel
  • 7,879
  • 6
  • 35
  • 56