Welcome Guest, Not a member yet? Register   Sign In
Using Validation on a 'Edit' screen
#1

[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
#2

[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')
            )
        )
    )
);
#3

[eluser]Unknown[/eluser]
Thanks,

That worked great.

Malcolm




Theme © iAndrew 2016 - Forum software by © MyBB