Welcome Guest, Not a member yet? Register   Sign In
Using form validation on edit form and having form re-population?
#1

[eluser]warpkid[/eluser]
Hi There,

I have a simple form in codeigniter that I wish to use for the editing or records. I am at the stage where my form is displayed and the values entered into the corresponding input boxes.

This is done by simply setting the values of said boxes to whatever they need to be in the view:

<input type="text" value="<?php echo $article['short_desc'];?>" name="short_desc" />

But, if I wish to use form_validation in codeigniter then I have to add thos code to my mark-up:

<input value="<?php echo set_value('short_desc')?>" type="text" name="short_desc" />

So not the value can be set with the set_value function should it need to be repopulated on error from the post data.

Is there a way to combine the two so that my edit form can show the values to be edited but also re-populate?

Thanks
#2

[eluser]billmce[/eluser]
You want to check out the form_validation page.
http://ellislab.com/codeigniter/user-gui...ation.html

About 1/2 down that page, where it discusses 'callbacks' is an example of what you're looking to accomplish.
#3

[eluser]warpkid[/eluser]
Hi,

I've checked out the sections on callbacks and can't see how they can be used to solve my issue. Unless I'm missing a trick.

I've reworded my question as I think it was a little confusing.

Thanks
#4

[eluser]mattpointblank[/eluser]
Try this:

Code:
<input type="text" name="email" value="<?php echo set_value('email', $user['email']); ?>" />

First time you load the form it'll show the $user['email'] value from your database. If you change this value then submit the form (but make a validation error somewhere) it'll remember the updated value you changed.




Theme © iAndrew 2016 - Forum software by © MyBB