Welcome Guest, Not a member yet? Register   Sign In
Validate an edit form
#5

[eluser]nanda[/eluser]
Here's the solution I use for my edit forms, it seems to work pretty good so far and does what I think you are asking for (without using 2 views).

Code:
<?php
if (!$this->validation->name && isset($event->name)) {
echo $event->name;
} else {
echo $this->validation->name;
}
?>

This checks if the validation variable is set first (if it is then the form must have been submitted, so this picks up changes), if it hasn't it takes whatever was stored in the database.

I normally have the code all on one line, but I've broken it up below to be easier to read. I pass a $data array in the controller to the view, the mysql result for my event data is stored in $data['event'] so you get the $event object as referenced below.

I'm probably going to put this in a plugin or helper for my own use as I like cleaner code in my views.


Messages In This Thread
Validate an edit form - by El Forum - 06-23-2008, 10:15 AM
Validate an edit form - by El Forum - 06-23-2008, 04:55 PM
Validate an edit form - by El Forum - 06-23-2008, 05:15 PM
Validate an edit form - by El Forum - 06-23-2008, 05:28 PM
Validate an edit form - by El Forum - 06-23-2008, 06:31 PM
Validate an edit form - by El Forum - 06-23-2008, 08:58 PM
Validate an edit form - by El Forum - 06-23-2008, 11:09 PM
Validate an edit form - by El Forum - 08-30-2008, 05:15 AM
Validate an edit form - by El Forum - 08-30-2008, 11:44 AM
Validate an edit form - by El Forum - 08-31-2008, 06:50 PM
Validate an edit form - by El Forum - 08-31-2008, 07:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB