Araquach Posted October 20, 2012 Share Posted October 20, 2012 I'm building a customer feedback form where upon submission a voucher is sent via SMS text message. I'm using the YiiMail extension to handle sending the text message. It's all working well. My only issue arrises when the applicant breaks up their mobile number with spaces when inputting it, as this doesn't validate in Swift mailer. What is the best approach? Do I need to create a new validation rule or does Yii provide one for this scenario? Or would you recommend creating a function to strip the spaces out after validation? If that's the case, how would I go about implementing this (I still struggle with where to place this kind of functionality - I'm pretty new to OOPHP). Would appreciate the help! Link to comment Share on other sites More sharing options...
Antonio Conte Posted October 21, 2012 Share Posted October 21, 2012 Strings can be handled like arrays. Do a for loop over the string, and check for white space for each char. Upon white space, change the string. Link to comment Share on other sites More sharing options...
Larry Posted October 22, 2012 Share Posted October 22, 2012 I don't think there's a Yii validation rule for this, but I could be wrong. I'd write Antonio's functionality into a method in the corresponding model. Link to comment Share on other sites More sharing options...
Araquach Posted October 24, 2012 Author Share Posted October 24, 2012 Thanks for your help guys, i'll give it a go. p.s. the anticipation for the new book is killing me Larry!! Link to comment Share on other sites More sharing options...
Larry Posted October 24, 2012 Share Posted October 24, 2012 Oh, no, don't want you dead! I'm very close to sending the first part to the tech editors, and then I'll create the site for selling it. Thanks for the interest! Link to comment Share on other sites More sharing options...
Recommended Posts