Welcome Guest, Not a member yet? Register   Sign In
set_value when editing
#1

[eluser]Unknown[/eluser]
I'm trying to display a simple edit form for editing users.
An input in the view could look like this:
<?php echo form_input('username', set_value('username', $user['username'])); ?>

So when I initially load the form I get the data from the db and set the variable "user" in the controller, so the $user['username'] gets displayed.
When the form is submitted I don't load anything from the db because from then on I only care about the POST data. But the helper throws an error:

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: user

So although it's not needed I have to set the variable in the controller?
If this is all right, seems a lot of unnecessary work? In CakePHP it would be:
<?php echo $form->input('username'); ?>




Theme © iAndrew 2016 - Forum software by © MyBB