Welcome Guest, Not a member yet? Register   Sign In
An easy solution for setting form input values for combined create/edit forms
#5

[eluser]Moobies[/eluser]
hi,

that's fine, but it does not address the fundamental issue with its use in prepopulating form values as nicely as possible. i presented 2 alternatives above, my option, and the only other option i could think of using set_value with a default.

so what do you think?

in fact, the set_value with a default on a create form (i.e. with no backing object) would cause a php error, so you'd either have to check for non-null or suppress the error, e.g.

Code:
<input type=“text” name=“name” value=”<?php echo set_value(‘name’, @$myobj->name) ?>” >

again, i think this is ugly when there is already conditional checks in the controller to determine whether a create or edit is happening.

set_value in the controller does not have any influence on the form input helper version of set_value and that's because set_value is actually returning the default value from the function. my solution actually places the value in the Form_validation's internal data array so it's found by the alias helper version too.

i still think my way is better unless you can convince me otherwise Smile)


Messages In This Thread
An easy solution for setting form input values for combined create/edit forms - by El Forum - 04-30-2009, 08:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB