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

[eluser]marcoss[/eluser]
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;
    }


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