<?php if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Cf_Validation
 *
 * @author sudhir
 */
class Cf_Validation extends CI_Validation
{
    public function __construct()
    {
        parent::CI_Validation();
    }

    public function set_checkbox($field = '', $value = '')
    {
        if ($field == '' or $value == '') {
            return '';
        }
        if (isset($_POST[$field])) {
            if ($_POST[$field] == $value || (is_array($_POST[$field]) && in_array($value, $_POST[$field]))) {
                return ' checked="checked"';
            }
        } elseif (isset($this->$field)) {
            if ($this->$field == $value || (is_array($this->$field) && array_search($value, $this->$field) !== false)) {
                return ' checked="checked"';
            }
        }
    }
}
