CodeIgniter Forums
Using Validation on a 'Edit' screen - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Using Validation on a 'Edit' screen (/thread-32841.html)



Using Validation on a 'Edit' screen - El Forum - 08-06-2010

[eluser]Unknown[/eluser]
OK, so I have set up the validation helper perfectly on my 'Add new entry' page and it works great.

Now I'm building the 'Edit entry' page and can't figure out how to combine the validation helper with pre-populating the form with the saved data.

Using the form helper I need to populate the inputs like this:

Code:
// Scheme name
$this->table->add_row(
    array(
        form_label('Scheme name', 's_name').NBS.form_error('s_name'),
        form_input(
            array(
            'id'    => 's_name',
            'name'    => 's_name',
            'class' => 'field',
            'value' => $scheme->s_name
            )
        )
    )
);

But without the:

Code:
'value' => set_value('s_name')

bit, how will the validation work?

Am I missing something obvious?

Many thanks,

Malcolm


Using Validation on a 'Edit' screen - El Forum - 08-07-2010

[eluser]verynewtothis[/eluser]
I would give this a try:
Code:
$this->table->add_row(
    array(
        form_label('Scheme name', 's_name').NBS.form_error('s_name'),
        form_input(
            array(
            'id'    => 's_name',
            'name'    => 's_name',
            'class' => 'field',
            'value' => !$this->input->post('s_name') ? $scheme->s_name : set_value('s_name')
            )
        )
    )
);



Using Validation on a 'Edit' screen - El Forum - 08-16-2010

[eluser]Unknown[/eluser]
Thanks,

That worked great.

Malcolm