Welcome Guest, Not a member yet? Register   Sign In
Unintuitive first parameter in set_value() function of the form helper
#2

[eluser]davidbehler[/eluser]
How should CI detect what field you are in?
It's a function call inside a function call..there's no way (99.9% sure at least) of telling what parameter was passed to the form_input function inside the set_value function.

And what if you are using the set_value function differently:
Code:
<input name="some_field" value="<?php echo set_value('some_field', 'first_load_value'); ?>" />

The only way I can think of right now that would reduce the amount of typing would be to use a custom wrapper function like this:
Code:
// place it in MY_form_helper.php in application/helpers

function form_input_set($name, $first_value)
{
  return form_input($name, set_value($name, $first_value));
}

and in your form you could would do this:
Code:
<?php echo form_input_set('some_field', 'first_load_value'); ?>


Messages In This Thread
Unintuitive first parameter in set_value() function of the form helper - by El Forum - 06-18-2011, 02:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB