Welcome Guest, Not a member yet? Register   Sign In
How do you edit an item?
#1

[eluser]JREAM[/eluser]
I want to Update with the ID from uri-segment(3),
so it would look like users/update/55

My question is, how do you populate the fields with the database info?
I know how to send queries and things, but how do i pop it into that form input?

View:
Code:
<?=validation_errors(); ?>

<?=form_open('users/create')?>

    <label>Login</label>    &lt;?=form_input('login', set_value('login'))?&gt;<br />
    <label>Password</label>    &lt;?=form_input('password', set_value('password'))?&gt;<br />
    <label>Email</label>    &lt;?=form_input('email', set_value('email'))?&gt;<br />
    <label>Type</label>        
    &lt;?=form_dropdown('type', array(
        0 => 'Client',
        5 => 'Employee',
        10 => 'Admin'), set_value('type'))?&gt;<br />
    <label></label>&lt;?=form_submit('submit', 'Create')?&gt;

&lt;?=form_close()?&gt;
#2

[eluser]Cro_Crx[/eluser]
set_value can take two parameters. The second is a default value. For example the login field. You could do this:

Code:
<label>Login</label>    &lt;?=form_input('login', set_value('login', $login))?&gt;<br />

And then just pass the $login variable to your view:

Code:
$data['login'] = $some->database->lookup();
$this->load->view('user_create_view', $data);
#3

[eluser]JREAM[/eluser]
wow easy, thanks!!




Theme © iAndrew 2016 - Forum software by © MyBB