[eluser]John5788[/eluser]
Hello, I just updated to CI 2.0.2 and I am running into some problems.
My form uses the form helpers, so I have a bunch of code that looks like this
Code:
<?php echo form_input("x", set_value("x", $input_x)); ?>
<?php echo form_input("y", set_value("y", $input_y)); ?>
<?php echo form_input("y", set_value("z", $input_z)); ?>
I am using the first parameter of set_value() for form validation error. The second parameter is default value on edit mode. I found this technique on the forum a long time ago.
I am trying to share the same form view so I don't have to duplicate code and this method worked well until 2.0.2. PHP ERROR notices are thrown because $input_x does not exist until I call the controller function in charge of populating $input_x, $input_y, $input_z. I am not sure why it didn't happen in the past, but I am curious how to get around this?
I know I can just add an if statement such as
Code:
<?php
if(isset($input_x))
{
echo form_input("x", $input_x);
}
else
{
echo form_input("x", set_value("x"));
}
?>
but it just looks too verbose. Any other approaches?
TLDR: I need some way to share same form view on add and edit. Solutions?