Posted by Alex Reisner on December 1, 2005 at 9:24pm
4 followers
| Project: | Drupal core |
| Version: | 4.7.x-dev |
| Component: | base system |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
The attached patch adds a #filter property to fields which allows cleanup of user values post-validation, given there are no errors. As an example, I find PHP's built-in trim() function to be a particularly useful filter (try '#filter' => array('trim' => array())), and stripping leading or trailing slashes from paths is always useful...
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| form.inc.filter.patch | 2.34 KB | Ignored: Check issue status. | None | None |
Comments
#1
Re-rolled patch for 1.28.
#2
is this step needed? requires changes to docs as well. perhaps use the validate step for filtering. also, the word 'filter' is used already. this is a 'post validate', 'pre save' step.
#3
Alex, why #submit is not proper for this? That's a post validate step and can be made so that it's before the $form_id .'_submit'
#4
I like the #filter property for the following reasons:
While it's true that the #filter property requires more code in form.inc, it will reduce the amount of form-defining code in modules, if it's used enough. I use it all the time with Formproc, but perhaps that's unusual.
#5
Alex, #submit can be any number of callbacks so I still think that you can get away with it. You can define #submit array in the form element defining array.
#6
-1. I agree with chx: just use #submit for filtering.
Closing issue due to a 1-year period of inactivity.