Adding a custom Sort field in Drupal In our business we assign tasks to users based on the last digit of a company ID. When I created the view for these users, it was simple to create a "Formula" field and use RIGHT(field name, 1) to get this value.

I'd like to make an exposed filter that will allow users to only see companies ending in, say, 5 (for example).

Question: Is using the "Sort" function the best way to do this, or is there another way to add filtering to a table created by a view? It would be wonderful to add text search filters to each column, but I'm not sure if this is possible.

Question: How do I create a new field and make it available in the "add field" interface?

Thanks! Rich (who isn't the normal drupal developer and was left to learn on his own)
Hi Rich who isn't the normal Drupal developer and was left to learn on his own. Welcome to Drupal.

I've encountered scenarios in which I had an exposed sort with a dropdown list and I needed to remove all the options that didn't fit my pattern. I used a hook_form_alter() that modified the '#options list for the element to unset() the items I didn't want to allow the user to select. However, this method doesn't prevent those items from showing when -All- is selected, so that may not work if that's an option for your users.

The way you'd add a new field is to create a custom field handler but it sounds like what you want might instead be a custom sort handler or a custom filter handler. The three are similar but not identical in their implementation.