Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.6

Request #5029 [PATCH] HTML_QuickForm filter support
Submitted: 2005-08-08 22:16 UTC
From: ieure at php dot net Assigned: wiesemann
Status: Closed Package: DB_Table
PHP Version: Irrelevant OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-08-08 22:16 UTC] ieure at php dot net
Description: ------------ This patch implements filter support for DB_Table-generated forms. In the column definition, you can now add: $col = array( 'someField' => array( 'type' => 'clob', ... 'qf_filters' => array( 'strtolower', 'htmlspecialchars', array('some_class', 'some_function') ) ), ... ); ...and so on. Filters are applied in the order they are declared. Unfortunately, you can only add regular functions and static class methods. There's no way to assign $this in class var definitions. I wanted to add a special key like _THIS_CLASS_, but it doesn't appear that there's any way to know what the correct class is from any function in DB_Table_QuickForm. I'm open to suggestions, if you have any. Patch: http://atomized.org/PEAR/DB_Table-filters.patch

Comments

 [2005-08-09 14:38 UTC] wiesemann
Wow, this will be a great addition to the package. As for the problem with $this: If you want to call the functions in the class static, maybe get_class($this) is the thing you are searching for. In my opinion it makes also sense to allow filters that apply to all form elements (e.g. 'strtolower', 'htmlspecialchars', 'trim', ...). They could be specified by a new parameter in getForm(). What do you think?
 [2005-08-09 18:49 UTC] ieure at php dot net
Right, I know about get_class(), but that won't work because you can't use the result of an expression for assigning a member variable. I'll see about implementing form-wide filtering in a couple days.
 [2005-08-09 21:12 UTC] pmjones
You can't use a function in a property declaration, but you could do so inside the constructor. class example extends DB_Table { function example() { $this->col['field_name']['qf_filters'] = array( array($this, 'filterMethod') ); } }
 [2005-08-13 13:22 UTC] wiesemann
I have applied your patch. There is now also a new parameter in getForm() which allows filters for all form elements. I'll commit it as soon as have I CVS karma for this package.
 [2005-08-17 18:10 UTC] wiesemann
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.