I’m pretty new to cakephp, I did the sample posts tutorial on the website and I’m now working on my first project.
Its pretty simple. The administrator pastes a list of emails and they become records in the database with a random password.
-
So, I want to register multiple emails by inputting em ‘foo@bar.com; bar@foo.com; com@foo.bar’ style in the same textbox. In the database they should become a record/email.
For one email my code is:
echo $this -> Form -> input(’email’);
echo $this -> Form -> input(‘code’, array(‘default’ => genRandomString())); -
I also wan’t to validate the adresses as emails later on. So could I use php’s explode and then validate em on one way or another?
Greetings
Jeff
Cake itself has a neat method to explode them:
( http://book.cakephp.org/2.0/en/core-utility-libraries/string.html#string )
yes, you can iterate over them and manually validating them one by one or putting them into an array saveAll() understands and use ‘validate’=>’first’ or ‘only’ with it.
( http://book.cakephp.org/2.0/en/models/data-validation/validating-data-from-the-controller.html#validating-data-from-the-controller )