Thursday, 5 September 2013

codeigniter validation error with field "required"

codeigniter validation error with field "required"

i have a problem with the validation form. It does not work if i put
"required", example:
public function updateBenefit(){
$result = array();
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('title', 'Nombre del Beneficio',
'required|alpha');
$this->form_validation->set_message('required', 'El campo %s es requerido');
if ($this->form_validation->run() == TRUE){
$actualBenefit = $this->data['benefit'];
$benefit =
BeneficiosManager::getInstance()->getHome($actualBenefit->id);
$benefit->title = ucfirst(strtolower(trim($_POST['beneficio'])));
$benefit->content = ucfirst(strtolower($_POST['descrip']));
$benefit->intro = ucfirst(strtolower($_POST['info']));
$benefit->active = $_POST['optionsRadios'];
$benefit->date = $_POST['fecha'];
BeneficiosManager::getInstance()->save($benefit);
$result['message'] = "successfull changes";
}else{
//no se validaron los datos ingresados
$result['message'] = "validation error";
}
echo json_encode($result);
}
what might the problem be?

No comments:

Post a Comment