Welcome Guest, Not a member yet? Register   Sign In
Function set_value() not working as expected
#17

[eluser]tison[/eluser]
For a quick fix, I've created this function to easily set empty rules - so that all fields get re-populated:

In /helpers/MY_form_helper.php

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Set empties
*
* Sets empty fields using set_value, hopefully they will fix this
*
*/
if ( ! function_exists('set_empty_rules'))
{
    function set_empty_rules($field_array)
    {
        if(isset($field_array) && is_array($field_array)):
            $mythis =& get_instance(); // grabbing our ci this instance
            foreach($field_array as $key => $val):
                $mythis->form_validation->set_rules($key,$val,'');
            endforeach;
        endif;
    }
}

And in your controller:

Code:
set_empty_rules(array('address'=>'Address','city'=>'City','state'=>'State','zip'=>'Zip'));
The function takes an array of key -> values where key = 'fieldname' and value='Field Error Message'


Messages In This Thread
Function set_value() not working as expected - by El Forum - 11-11-2008, 09:51 AM
Function set_value() not working as expected - by El Forum - 11-11-2008, 10:22 AM
Function set_value() not working as expected - by El Forum - 11-11-2008, 12:34 PM
Function set_value() not working as expected - by El Forum - 11-12-2008, 01:20 PM
Function set_value() not working as expected - by El Forum - 11-23-2008, 10:16 PM
Function set_value() not working as expected - by El Forum - 11-23-2008, 10:47 PM
Function set_value() not working as expected - by El Forum - 11-24-2008, 12:16 AM
Function set_value() not working as expected - by El Forum - 01-19-2009, 10:30 AM
Function set_value() not working as expected - by El Forum - 02-08-2009, 12:21 AM
Function set_value() not working as expected - by El Forum - 02-08-2009, 04:32 AM
Function set_value() not working as expected - by El Forum - 02-08-2009, 10:16 AM
Function set_value() not working as expected - by El Forum - 02-08-2009, 11:59 AM
Function set_value() not working as expected - by El Forum - 02-24-2009, 11:52 AM
Function set_value() not working as expected - by El Forum - 07-15-2009, 10:45 AM
Function set_value() not working as expected - by El Forum - 07-15-2009, 12:33 PM
Function set_value() not working as expected - by El Forum - 11-10-2009, 11:42 AM
Function set_value() not working as expected - by El Forum - 11-10-2009, 12:08 PM
Function set_value() not working as expected - by El Forum - 12-13-2009, 09:43 PM
Function set_value() not working as expected - by El Forum - 01-01-2010, 11:42 PM
Function set_value() not working as expected - by El Forum - 01-02-2010, 09:39 AM
Function set_value() not working as expected - by El Forum - 05-03-2010, 12:45 AM
Function set_value() not working as expected - by El Forum - 06-17-2010, 03:34 AM
Function set_value() not working as expected - by El Forum - 06-25-2010, 06:32 AM
Function set_value() not working as expected - by El Forum - 08-17-2010, 03:08 PM
Function set_value() not working as expected - by El Forum - 09-13-2010, 09:38 PM
Function set_value() not working as expected - by El Forum - 09-23-2010, 04:33 AM
Function set_value() not working as expected - by El Forum - 10-12-2010, 01:33 PM
Function set_value() not working as expected - by El Forum - 12-15-2010, 02:08 PM
Function set_value() not working as expected - by El Forum - 01-19-2011, 02:30 AM
Function set_value() not working as expected - by El Forum - 04-20-2011, 09:22 AM
Function set_value() not working as expected - by El Forum - 05-04-2011, 06:30 AM
Function set_value() not working as expected - by El Forum - 05-05-2011, 03:19 PM
Function set_value() not working as expected - by El Forum - 06-21-2011, 01:12 AM
Function set_value() not working as expected - by El Forum - 08-05-2011, 05:03 PM
Function set_value() not working as expected - by El Forum - 08-05-2011, 05:14 PM
Function set_value() not working as expected - by El Forum - 04-03-2012, 10:18 AM
Function set_value() not working as expected - by El Forum - 05-14-2012, 01:50 PM
Function set_value() not working as expected - by El Forum - 07-28-2012, 01:42 AM
Function set_value() not working as expected - by El Forum - 07-28-2012, 02:22 AM
Function set_value() not working as expected - by El Forum - 08-26-2012, 12:58 PM
Function set_value() not working as expected - by El Forum - 08-26-2012, 01:16 PM
Function set_value() not working as expected - by El Forum - 08-26-2012, 11:07 PM
Function set_value() not working as expected - by El Forum - 08-27-2012, 10:07 AM
Function set_value() not working as expected - by El Forum - 08-27-2012, 07:08 PM
Function set_value() not working as expected - by El Forum - 02-13-2014, 10:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB