Form Validation validating default value

#1
[eluser]cmark[/eluser]
Hi there, im getting problems during the validation process:

Code:
$this->form_validation->set_rules('titulo', 'Titulo', 'required');

In the View, i used the set_value function, but when i attempt in order to validate, the form_validation doesn't found any problem with the default value (in this case, 'Titulo').
What can i do?

Ps: sorry with my eng, i'm really very new.

Thanks!

#2
[eluser]cmark[/eluser]
I solved it in this way:

Code:
<?

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



class MY_Form_validation extends CI_Form_validation

{

    function MY_Form_validation($config = array())

    {

        parent::CI_Form_validation($config);

    }



    function run($group = '')

    {

        foreach ($this->_field_data as $field => $row)

        {

            // Fetch the data from the corresponding $_POST array and cache it in the _field_data array.

            // Depending on whether the field name is an array or a string will determine where we get it from.



            if ($row['is_array'] == TRUE)

            {

                $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']);

            }

            else

            {

                if (isset($_POST[$field]) AND $_POST[$field] != "")

                {

                    $this->_field_data[$field]['postdata'] = $_POST[$field];

                }

            }



            if ($row['label'] == $this->_field_data[$field]['postdata'] )

            {

                $message = 'Por favor, completa el '. $row['label'];



                // Save the error message

                $this->_field_data[$row['field']]['error'] = $message;



                if ( ! isset($this->_error_array[$row['field']]))

                {

                    $this->_error_array[$row['field']] = $message;

                }

            }



        }



        return parent::run($group);

    }

}



?>

Maybe exists another way to validate the Label without a callback; but really i don't know. Thanks,

Marco


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.