Welcome Guest, Not a member yet? Register   Sign In
Pre-populated inputs and validation
#1

[eluser]codex[/eluser]
Hi,

I'm not sure how to implement this, so I could use a bit of advice. I have an 'edit profile' form which is prepopulated with the user's data. Some fields can't be left empty so his needs to be validated. For instance, a user can edit his name, but he can't completely erase it.

To validate I have to populate the input value like so (it's based on an own helper function, last option is 'value'):

Code:
<?php echo input_text("user_name", 20, "input_text", $this->validation->user_name)?>

But this way I can't populate the initial value with '$query[0]->user_name'. What can I do?

I thought of this:

Code:
<?php
if (!$this->input->post('user_name')) {
$name = $query[0]->user_first_name }
else { $name = $this->validation->user_name
}
echo input_text("user_first_name", 20, "input_text", $name)?>

But then I get an 'undefined variable' error. And something tells me I'm not thinking correctly ;-)


Messages In This Thread
Pre-populated inputs and validation - by El Forum - 08-14-2007, 06:32 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 09:31 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 09:37 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 09:45 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 10:06 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 03:25 PM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 04:28 PM
Pre-populated inputs and validation - by El Forum - 08-17-2007, 09:29 AM
Pre-populated inputs and validation - by El Forum - 08-18-2007, 05:05 PM
Pre-populated inputs and validation - by El Forum - 10-20-2007, 12:03 PM
Pre-populated inputs and validation - by El Forum - 10-22-2007, 12:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB