Welcome Guest, Not a member yet? Register   Sign In
Reusing the same form code for creating and editing
#6

[eluser]ericsodt[/eluser]
[quote author="marcoss" date="1191279371"]The code is under the GPL

It is just a helper function, no security checks are performed, they are supposed to be done prior the data is used, and of course it is very primitive, so any enhancement is welcomed.

Code:
function field($key = '', $data = '') {
    
        global $CI;
        
        if (is_object($data) && property_exists($data, $key)) :
            $value = $data->$key;
        elseif (is_object($data) && !property_exists($data, $key)) :
            $value = '';
        else:
            $value = $data;
        endif;
        
        $post = $CI->input->post($key);
                
        if($post) :
            return $post;
        elseif ( ($value) && !empty($value) ) :
            return $value;
        else :
            return '';
        endif;
    }
[/quote]

Thanks for posting, are there any examples of how to use, for a point of reference? or should I extend the validation class and implement over write the existing field method


Messages In This Thread
Reusing the same form code for creating and editing - by El Forum - 06-24-2007, 11:42 AM
Reusing the same form code for creating and editing - by El Forum - 06-24-2007, 01:52 PM
Reusing the same form code for creating and editing - by El Forum - 06-24-2007, 06:58 PM
Reusing the same form code for creating and editing - by El Forum - 10-01-2007, 10:25 AM
Reusing the same form code for creating and editing - by El Forum - 10-01-2007, 11:56 AM
Reusing the same form code for creating and editing - by El Forum - 10-01-2007, 12:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB