2
is it possible to validate a form input using the GET method? When I define that the form method is POST the form_validation works but when I define that is GET the validation returns me false. The code is basically this:
HTML
<form method="GET" action="<?=base_url('pesquisar');?>" role="form">
<div class="input-group">
<input type="text" class="form-control" name="busca" required>
<span class="input-group-btn">
<button type="submit" class="btn btn-plan">Pesquisar</button>
</span>
</div><!-- /input-group -->
</form>
CONTROLLER
public function pesquisar() {
$this->form_validation->set_rules('busca', 'Termo de Busca', 'required|trim');
if ($this->form_validation->run()) {
echo $this->input->get('busca');
} else {
echo 'não validou'; // Sempre entra aqui
}
}
I saw the following solution, but I didn’t think it was quite right:
$_POST['busca'] = $this->input->get('busca'); // só então executar a validação...
It worked perfectly. Thanks!
– Paulo Weverton