Part of the EllisLab Network
   
 
clear values function for validation
Posted: 10 July 2008 03:25 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  251
Joined  05-28-2008

I would like to request a clear_values function for the validation library. Often I find myself reloading the same form, instead of showing a success page, but if you do that, the form gets repopulated with submitted values. The values don’t get cleaned. I would suggest either cleaning the values automatically upon validation, or adding a separate function for it.

xwero wrote a little function for it that would make a good addition to the library I think.

function clear_values()    
    
{
        $fieldnames
= array_keys($this->_rules);
        foreach(
$fieldnames as $fieldname)
        
{
            
if(isset($this->$fieldname))
            
{
                
unset($this->$fieldname);
            
}
        }
    }

doing it automatically could happen in the run() function… Maybe add a variable: function run (clear_values = false) {}, and then add that function in an if statement…

Profile
 
 
Posted: 14 July 2008 05:48 AM   [ Ignore ]   [ # 1 ]  
Grad Student
Avatar
Rank
Total Posts:  48
Joined  03-21-2007

Nice Bramme.

 Signature 

A nerd is someone whose life revolves around computers and technology.
A geek is someone whose life revolves around computers and technology, and likes it!

Files
helpersGzip - cache - serve: assets

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 60658 Total Logged-in Users: 24
Total Topics: 73063 Total Anonymous Users: 0
Total Replies: 393968 Total Guests: 284
Total Posts: 467031    
Members ( View Memberlist )