Skip to content

Instantly share code, notes, and snippets.

@miqueiaspenha
Last active November 10, 2017 19:22
Show Gist options
  • Save miqueiaspenha/d3ce4fa45741bf09452148724bce1eed to your computer and use it in GitHub Desktop.
Save miqueiaspenha/d3ce4fa45741bf09452148724bce1eed to your computer and use it in GitHub Desktop.
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Welcome extends CI_Controller
{
public function index()
{
$this->form_validation->set_rules('quantidade', 'Quantidade', 'trim|required|min_length[5]|callback_checa_algo');
if ($this->form_validation->run()) {
echo 'Cadastrado';
die();
}
$this->load->view('welcome_message');
}
public function checa_algo($algo)
{
if (!$algo) {
$this->form_validation->set_message('checa_algo', 'Formato de algo inválido.');
return false;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment