<?php
/**
 * CodeIgniter library
 *
 * @category CodeIgniter
 * @license /_licenses/untermStrich/agb_normal.pdf
 * @author Christian Koller
 * @copyright 2009 untermStrich
 * @package libraries
 * @version $Id$
*/

if (!defined('BASEPATH')) { exit('No direct script access allowed'); }

/**
 * Add's additional functionality to the form validation class
 */
class My_Form_validation extends CI_Form_validation
{

    /**
     * Run the Validator
     *
     * @param   string  $group  Optional A group to read the validation from
     * @return  boolean
     */
    public function run($group='')
    {
        // Load the language file containing error messages
        $this->CI->lang->load('form_validation', LANG);

        return parent::run($group);
    }


    public function reset()
    {
        $this->_error_array = array();
        $this->_field_data = array();
        $this->_safe_form_data = false;
    }

	/**
	 * Get the value from a form
	 *
	 * Permits you to repopulate a form field with the value it was submitted
	 * with, or, if that value doesn't exist, with the $_POST or with default
	 *
	 * @access	public
	 * @param	string	the field name
	 * @param	string
	 * @return	void
	 */
	function set_value($field = '', $default = '')
	{
            if (isset($this->_field_data[$field])) {
                return $this->_field_data[$field]['postdata'];
            } else if (isset($_POST[$field])) {
                return $_POST[$field];
            } else {
                return $default;
            }
	}
    
} // END class My_form_validation
