Friday, April 12, 2013

Re: How to remove trailing spaces from data submitted on form

have you debugged $this->data?
Then you would have found out that you are trying to trim an array here, which will not work..

foreach ($this->data[$this->alias] as $key => $value) {      if (is_string($value) {          $this->data[$this->alias][$key] = rtrim($value);      }  }


Am Freitag, 12. April 2013 09:42:51 UTC+2 schrieb Sam:
Dear Cakephp experts,

I would like to remove trailing spaces from data submitted on a form. I use the code below in BeforeSave()

foreach ($this->data as $key => $value) {      if (is_string($value)       $this->data[$key] = rtrim($value);  }
However, the spaces are still there. What did I do wrong or is there any better method? 

I am using Cakephp 2.2.1. 

Thank you very much if you can help.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: