We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Question, Discussion

Remove spaces from field

Is there a way to remove spaces from a text field.

I have tried using replace=" |" but it doesn't seem to do anything.

For example, I have a simple text field holding a phone number. the phone number is entered like 01452 000 000 but I would like to output like 01452000000.

Marc Sanders

Marc Sanders 0 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need to use a template filter to achieve that.


Thats great, didn't realise this was available - Got a simple one setup and working.

    class PerchTemplateFilter_space extends PerchTemplateFilter {
        public function filterAfterProcessing($value, $valueIsMarkup = false) {
            if ($this->Tag->type == 'text') {
            return str_replace(' ', '', $value);

    PerchSystem::register_template_filter('space', 'PerchTemplateFilter_space');

Thank you Drew