Good Morning,
I have a set of variables being passed to a form via CodeIgniter's MVC setup, however I am trying to keep from duplicating the form elements if at all possible.
However, I am getting undefined variable errors (for good reasons) when trying to build the input fields on the "add" form.
I know I can duplicate the form elements, one with the $result['data'] and one without, but I would really prefer not.
How would you suggest I build the form below so that I only pass the form_xxxx() functions once?
I have a set of variables being passed to a form via CodeIgniter's MVC setup, however I am trying to keep from duplicating the form elements if at all possible.
However, I am getting undefined variable errors (for good reasons) when trying to build the input fields on the "add" form.
I know I can duplicate the form elements, one with the $result['data'] and one without, but I would really prefer not.
How would you suggest I build the form below so that I only pass the form_xxxx() functions once?
Code:
if(isset($result) && is_array($result)) // check to see if data is available to fill form
{
$action = 'welcome/update';
$submit = 'Update Old';
} else {
$action = 'welcome/insert';
$submit = 'Add New';
}
echo form_open($action);
echo form_input('service_id',$result['service_id']); // undefined variable
echo form_input('updated_date',$result['updateddate']); // undefined variable
echo form_submit('submit',$submit);
echo form_close();
Comment