Re: Validation problem
It started to work, however I still don't know why. ;-) Well, beginnings are difficult... Thanks for 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+unsubscr...@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. For more options, visit https://groups.google.com/groups/opt_out.
Re: Validation problem
Thanks a lot. This > $this->Student->set($this->request->data) > helped. Now most of the fields are being validated. Only two left: 'password' => array( > 'rule'=> array('minLength', '6'), > 'required'=>true, > 'message' => 'Co najmniej 6 znaków' > ), > 'moodle_password' => array( > 'rule'=> array('equalTo', 'some_text'), > 'required'=>true, > 'message' => 'Błędne hasło Moodle' > ), > Both don't validate. I don't know why. :-( Regards, Slawek. -- 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+unsubscr...@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. For more options, visit https://groups.google.com/groups/opt_out.
Re: Validation problem
On Monday, 10 February 2014 15:53:45 UTC+1, Slawomir Wawak wrote: > > Hi! > I try to create some validation to my form. I followed some forums and > blogs looking for solution, but nothing helps. > > My controller looks like this: > > public function add() { >> if ($this->request->is('post')) { >> $this->Student->create(); >> *if ($this->Student->validates()) {* >> . >> > The above is attempting to validate an empty Student object - Student doesn't have any form data in it. You are missing: $this->Student->set($this->request->data) or similar. > When I enable "required => true" form fails each time, even when correct. > Because the form data isn't in/on the model - you're validating nothing. > When I show debug($this->Student->data) all data is there. > Where are you doing that? AD -- 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+unsubscr...@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. For more options, visit https://groups.google.com/groups/opt_out.
Validation problem
Hi! I try to create some validation to my form. I followed some forums and blogs looking for solution, but nothing helps. My controller looks like this: public function add() { > if ($this->request->is('post')) { > $this->Student->create(); > *if ($this->Student->validates()) {* > . > And my model validation: public $validate = array( >> 'firstname' => array( >> 'alphaNumeric' => array( >> 'rule' => 'alphaNumeric', >> 'required'=>true, >> 'message' => 'Tylko litery w imieniu' >> ), >> 'minLength' => array( >> 'rule'=> array('minLength', '3'), >> 'required'=>true, >> 'message' => 'Wpisz pełne imię' >> ) >> ), .. > > When I remove "required => true" form passes validation even with errors! When I enable "required => true" form fails each time, even when correct. The only field that works correct is email: > 'email' => array('email', true), > When I show debug($this->Student->data) all data is there. However I suppose, that somehow validation may be somehow unable to see this. Please help me find solution to this problem. Regards, Slawek. -- 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+unsubscr...@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. For more options, visit https://groups.google.com/groups/opt_out.
Re: saveAll and Validation Problem
echo $this->Form->input('Model.0.name'); echo $this->Form->input('Model.1.name'); echo $this->Form->input('Model.2.name'); Em quinta-feira, 6 de junho de 2013 12h30min10s UTC-3, gloop escreveu: > > Hello Cake-Fans, > > i try to save more than 1 entry in the database. > > Example: > > *index.ctp* > echo $this->Form->create('Item'); > echo $this->Form->input('0.Item.name'); > echo $this->Form->input('1.Item.name'); > echo $this->Form->end('save'); > > *Item.php* > class Item extends AppModel { > var $validate = array( > 'name' => 'email' > ); > } > > *ItemsController.php* > public function index() { > if($this->request->is('post')){ > if($this->Item->saveAll($this->request->data)) > $this->Session->setFlash("saved successful"); > else{ > $this->Session->setFlash("saving error"); > debug($this->Item->validationErrors); > } > } > } > > > When i try to save a non-email value i get the "saving error" but no > message for the input fields. The validationErrors are: > > array( > (int) 0 => array( > 'name' => array( > (int) 0 => 'This field cannot be left blank' > ) > ), > (int) 1 => array( > 'name' => array( > (int) 0 => 'This field cannot be left blank' > ) > ) > ) > > Is that the correct way to save many entrys? Whats my failure? > > Many Thanks for your help > Steffen > -- 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+unsubscr...@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.
saveAll and Validation Problem
Hello Cake-Fans, i try to save more than 1 entry in the database. Example: *index.ctp* echo $this->Form->create('Item'); echo $this->Form->input('0.Item.name'); echo $this->Form->input('1.Item.name'); echo $this->Form->end('save'); *Item.php* class Item extends AppModel { var $validate = array( 'name' => 'email' ); } *ItemsController.php* public function index() { if($this->request->is('post')){ if($this->Item->saveAll($this->request->data)) $this->Session->setFlash("saved successful"); else{ $this->Session->setFlash("saving error"); debug($this->Item->validationErrors); } } } When i try to save a non-email value i get the "saving error" but no message for the input fields. The validationErrors are: array( (int) 0 => array( 'name' => array( (int) 0 => 'This field cannot be left blank' ) ), (int) 1 => array( 'name' => array( (int) 0 => 'This field cannot be left blank' ) ) ) Is that the correct way to save many entrys? Whats my failure? Many Thanks for your help Steffen -- 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+unsubscr...@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.
action validation problem
Hi Guys, the situation: i have a controller UserController that has actions like 'add','edit' ... (surprise surprise! :) ) i'd like to have custom validations for the particular actions. i tried Multiple Validation Sets in the UserModel with validateAdd, validateEdit... but the controller doesn't access them, only the normal (general) validation ($this->validate) is done, but not the custom ones like validateAdd.. im using cakephp 1.3.2 whats the best practice here ? is validateAdd still possible in cake 1.3 ? the tips i found where for 1.2.. im not sure tx in advance Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
Thanks grigri, cricket, I've got it working now - I worked out the "+" thing from a regex tutorial. On 14 July 2010 02:09, cricket wrote: > On Tue, Jul 13, 2010 at 2:57 PM, Felix Fennell > wrote: >> Removing the /i doesn't do anything unfortunately - I read the >> handbook page too and thought it should work. >> >> They use this to check for any string using alphanumeric characters + >> dashes + underscores; >> >> [0-9a-zA-Z_-] >> >> So I would have though that using [a-zA-Z] would work for just upper >> and lowercase letters. > > [-_A-Za-z]+ > > Note the "+". You want to specify that the string can be one or more > characters. Without it, and with the ^ and $ wrapping the brackets, > you're specifying that it must be just a single char. > >> Just so I'm not doing anything stupid, everytime I update the >> validation in the model and upload it, I then delete what ever files >> are in the /app/tmp/cache/models directory - is there anything else I >> need to do. > > That should do it, Although, if debug is > 0 that shouldn't be an issue, > AFAIK. > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
On Tue, Jul 13, 2010 at 2:57 PM, Felix Fennell wrote: > Removing the /i doesn't do anything unfortunately - I read the > handbook page too and thought it should work. > > They use this to check for any string using alphanumeric characters + > dashes + underscores; > > [0-9a-zA-Z_-] > > So I would have though that using [a-zA-Z] would work for just upper > and lowercase letters. [-_A-Za-z]+ Note the "+". You want to specify that the string can be one or more characters. Without it, and with the ^ and $ wrapping the brackets, you're specifying that it must be just a single char. > Just so I'm not doing anything stupid, everytime I update the > validation in the model and upload it, I then delete what ever files > are in the /app/tmp/cache/models directory - is there anything else I > need to do. That should do it, Although, if debug is > 0 that shouldn't be an issue, AFAIK. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
Ok, I've got everything working now! The rules I have ended up with are; First name: 'rule' => '/^[a-zA-Z]+$/', Second name: 'rule' => '/^[a-zA-Z]+$/', Company name: 'rule' => '/^[a-zA-Z\s]+$/', (Company name should also allow spaces) I realise that I could use "/i" instead of the [a-zA-Z] bit but as its working I don't really want to mess it up. So thanks again to both McBuck DGAF and Dr. Loboto for your help in fixing this. Felix On 14 July 2010 14:44, McBuck DGAF wrote: > I would defer to Dr. Loboto on this, since he obviously knows more > about regex than I do. Maybe he can suggest the correct rule . . . ? > > My only response to your last post, Felix, is that you cannot remove "/ > i" since the "/" is required to delimit the regex. In other words, > just remove"i". > > Good luck. > > On Jul 14, 3:32 am, "Dr. Loboto" wrote: > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
A regexp that only allows letters, numbers and spaces? '/^[a-z0-9\\x20]*$/i' A regexp that only allows "words" of letters and numbers, each separated by a single space: '/^(?:[a-z0-9]+\\x20)*[a-z0-9]$/' hth grigri On Jul 14, 2:44 pm, McBuck DGAF wrote: > I would defer to Dr. Loboto on this, since he obviously knows more > about regex than I do. Maybe he can suggest the correct rule . . . ? > > My only response to your last post, Felix, is that you cannot remove "/ > i" since the "/" is required to delimit the regex. In other words, > just remove"i". > > Good luck. > > On Jul 14, 3:32 am, "Dr. Loboto" wrote: Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
I would defer to Dr. Loboto on this, since he obviously knows more about regex than I do. Maybe he can suggest the correct rule . . . ? My only response to your last post, Felix, is that you cannot remove "/ i" since the "/" is required to delimit the regex. In other words, just remove"i". Good luck. On Jul 14, 3:32 am, "Dr. Loboto" wrote: Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
Rule '/^[a-z]$/i' accepts strictly one latin symbol in any case. Example: 'a' or 'B'. Rule '/^[a-z][A-Z]$/i' is same as '/^[a-z][A-Z]$/' and accept strictly two latin symbols, first in lowercase and second in upper. Example: 'aB'. Rule '/^[a-zA-Z]$/i' is same as '/^[a-zA-Z]$/' and same as '/^[a-z]$/ i'. So look upper: it accepts strictly one latin symbol in any case. Example: 'a' or 'B'. So these rules should always fail for username/name/company/etc unless you want them to be 1 symbol. On Jul 14, 1:57 am, Felix Fennell wrote: > Removing the /i doesn't do anything unfortunately - I read the > handbook page too and thought it should work. > > They use this to check for any string using alphanumeric characters + > dashes + underscores; > > [0-9a-zA-Z_-] > > So I would have though that using [a-zA-Z] would work for just upper > and lowercase letters. > > Just so I'm not doing anything stupid, everytime I update the > validation in the model and upload it, I then delete what ever files > are in the /app/tmp/cache/models directory - is there anything else I > need to do. > > Felix. > > On 13 July 2010 19:37, McBuck DGAF wrote: > > > > > I thought the "i" at the end of the rule I suggested would make it > > case insensitive, as described in the manual. (Like I said, regex is > > not my thing, I am still learning there . . .) Anyway, try removing > > the "i" from the end of the last rule you suggested (ie, '/^[a-zA-Z] > > $/') and see if that works. > > > On Jul 13, 1:36 pm, Felix wrote: > >> OK, that validation rule works, kinda. > > >> If I remove the validation for the company name (temporarily) the rest > >> of the form validation works, with one exception. > > >> The new regex doesn't allow for upper case letters, only lower case. > > >> I tried changing it from; '/^[a-z]$/i' > > >> to: '/^[a-z][A-Z]$/i' --didn't work > > >> to: '/^[a-zA-Z]$/i' --didn't work > > >> I think there's something basic I'm missing here! > > >> As for the company name that still gives the same errors as before. > > >> Thanks for your help thus far, Felix. > > >> On Jul 13, 3:13 pm, McBuck DGAF wrote: > > >> > Sorry, I wasn't looking at the regex itself, I was just looking at the > >> > way you implemented it (and we have not addressed your 'company_name' > >> > issue at all, but the solution here should be readily adaptable to > >> > that). > > >> > I am no regex expert, but wouldn't the following get you what you > >> > want?: > > >> > 'rule' => '/^[a-z]$/i', > > >> > (the regex must be delimited by "/", which is probably the source of > >> > your current error) > > >> > On Jul 12, 7:18 pm, Felix wrote: > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
Removing the /i doesn't do anything unfortunately - I read the handbook page too and thought it should work. They use this to check for any string using alphanumeric characters + dashes + underscores; [0-9a-zA-Z_-] So I would have though that using [a-zA-Z] would work for just upper and lowercase letters. Just so I'm not doing anything stupid, everytime I update the validation in the model and upload it, I then delete what ever files are in the /app/tmp/cache/models directory - is there anything else I need to do. Felix. On 13 July 2010 19:37, McBuck DGAF wrote: > I thought the "i" at the end of the rule I suggested would make it > case insensitive, as described in the manual. (Like I said, regex is > not my thing, I am still learning there . . .) Anyway, try removing > the "i" from the end of the last rule you suggested (ie, '/^[a-zA-Z] > $/') and see if that works. > > On Jul 13, 1:36 pm, Felix wrote: >> OK, that validation rule works, kinda. >> >> If I remove the validation for the company name (temporarily) the rest >> of the form validation works, with one exception. >> >> The new regex doesn't allow for upper case letters, only lower case. >> >> I tried changing it from; '/^[a-z]$/i' >> >> to: '/^[a-z][A-Z]$/i' --didn't work >> >> to: '/^[a-zA-Z]$/i' --didn't work >> >> I think there's something basic I'm missing here! >> >> As for the company name that still gives the same errors as before. >> >> Thanks for your help thus far, Felix. >> >> On Jul 13, 3:13 pm, McBuck DGAF wrote: >> >> > Sorry, I wasn't looking at the regex itself, I was just looking at the >> > way you implemented it (and we have not addressed your 'company_name' >> > issue at all, but the solution here should be readily adaptable to >> > that). >> >> > I am no regex expert, but wouldn't the following get you what you >> > want?: >> >> > 'rule' => '/^[a-z]$/i', >> >> > (the regex must be delimited by "/", which is probably the source of >> > your current error) >> >> > On Jul 12, 7:18 pm, Felix wrote: > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
I thought the "i" at the end of the rule I suggested would make it case insensitive, as described in the manual. (Like I said, regex is not my thing, I am still learning there . . .) Anyway, try removing the "i" from the end of the last rule you suggested (ie, '/^[a-zA-Z] $/') and see if that works. On Jul 13, 1:36 pm, Felix wrote: > OK, that validation rule works, kinda. > > If I remove the validation for the company name (temporarily) the rest > of the form validation works, with one exception. > > The new regex doesn't allow for upper case letters, only lower case. > > I tried changing it from; '/^[a-z]$/i' > > to: '/^[a-z][A-Z]$/i' --didn't work > > to: '/^[a-zA-Z]$/i' --didn't work > > I think there's something basic I'm missing here! > > As for the company name that still gives the same errors as before. > > Thanks for your help thus far, Felix. > > On Jul 13, 3:13 pm, McBuck DGAF wrote: > > > Sorry, I wasn't looking at the regex itself, I was just looking at the > > way you implemented it (and we have not addressed your 'company_name' > > issue at all, but the solution here should be readily adaptable to > > that). > > > I am no regex expert, but wouldn't the following get you what you > > want?: > > > 'rule' => '/^[a-z]$/i', > > > (the regex must be delimited by "/", which is probably the source of > > your current error) > > > On Jul 12, 7:18 pm, Felix wrote: Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
OK, that validation rule works, kinda. If I remove the validation for the company name (temporarily) the rest of the form validation works, with one exception. The new regex doesn't allow for upper case letters, only lower case. I tried changing it from; '/^[a-z]$/i' to: '/^[a-z][A-Z]$/i' --didn't work to: '/^[a-zA-Z]$/i' --didn't work I think there's something basic I'm missing here! As for the company name that still gives the same errors as before. Thanks for your help thus far, Felix. On Jul 13, 3:13 pm, McBuck DGAF wrote: > Sorry, I wasn't looking at the regex itself, I was just looking at the > way you implemented it (and we have not addressed your 'company_name' > issue at all, but the solution here should be readily adaptable to > that). > > I am no regex expert, but wouldn't the following get you what you > want?: > > 'rule' => '/^[a-z]$/i', > > (the regex must be delimited by "/", which is probably the source of > your current error) > > On Jul 12, 7:18 pm, Felix wrote: Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
Sorry, I wasn't looking at the regex itself, I was just looking at the way you implemented it (and we have not addressed your 'company_name' issue at all, but the solution here should be readily adaptable to that). I am no regex expert, but wouldn't the following get you what you want?: 'rule' => '/^[a-z]$/i', (the regex must be delimited by "/", which is probably the source of your current error) On Jul 12, 7:18 pm, Felix wrote: Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
Hi, thanks for the reply - I have updated the validation rules in the model with your suggestion, I get the following errors back for data that should be valid (ie. allowed) == Warning (2): preg_match() [function.preg-match]: No ending delimiter '^' found [CORE/cake/libs/model/model.php, line 2571] Notice (8): Undefined offset: 0 [CORE/cake/libs/model/model.php, line 2550] Warning (512): Could not find validation handler for company_name [CORE/cake/libs/model/model.php, line 2573] == The validation rule should only allow a user to input lower and upper case letters - no numbers spaces or punctuation. (I'm hoping thats what my original expressions did!) The "Account" model now reads as; == array( 'rule' => 'email', 'message' => 'Email must be valid.', 'allowEmpty' => false ), 'password' => array( 'rule' => array('minlength', 6), 'message' => 'Passwords must be six (6) characters or more.', 'allowEmpty' => false ), 'first_name' => array( 'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$', 'message' => 'Names can only contain letters.', 'allowEmpty' => false ), 'second_name' => array( 'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$', 'message' => 'Names can only contain letters.', 'allowEmpty' => false ), 'company_name' => array( 'rule' => array('custom' => '(\w(\s)?)+'), 'message' => 'Company names can only contain letters, numbers and spaces.' ), /* 'terms_accepted' => array( 'rule' => array('boolean'), 'required' => true, 'message' => 'You must agree to the terms and conditions and privacy policy.', ) */ ); } ?> == On Jul 12, 2:39 pm, McBuck DGAF wrote: > Instead of: > > > 'rule' => array('custom' => > > '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$'), > > Could you try: > > 'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)* > $', > > If that works, and you use this regular expression more than once, you > could consider implementing a custom validation rule as described > here: > > http://book.cakephp.org/view/1179/Custom-Validation-Rules > > On Jul 11, 5:41 pm, Felix wrote: > > > > > Hi, I have an odd validation issue I can't work out. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
Hi, thanks for the reply - I have updated the validation rules in the model with your suggestion, I get the following errors back for data that should be valid (ie. allowed) == Warning (2): preg_match() [function.preg-match]: No ending delimiter '^' found [CORE/cake/libs/model/model.php, line 2571] Notice (8): Undefined offset: 0 [CORE/cake/libs/model/model.php, line 2550] Warning (512): Could not find validation handler for company_name [CORE/cake/libs/model/model.php, line 2573] == The validation rule should only allow a user to input lower and upper case letters - no numbers spaces or punctuation. (I'm hoping thats what my original expressions did!) The "Account" model now reads as; == array( 'rule' => 'email', 'message' => 'Email must be valid.', 'allowEmpty' => false ), 'password' => array( 'rule' => array('minlength', 6), 'message' => 'Passwords must be six (6) characters or more.', 'allowEmpty' => false ), 'first_name' => array( 'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$', 'message' => 'Names can only contain letters.', 'allowEmpty' => false ), 'second_name' => array( 'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$', 'message' => 'Names can only contain letters.', 'allowEmpty' => false ), 'company_name' => array( 'rule' => array('custom' => '(\w(\s)?)+'), 'message' => 'Company names can only contain letters, numbers and spaces.' ), /* 'terms_accepted' => array( 'rule' => array('boolean'), 'required' => true, 'message' => 'You must agree to the terms and conditions and privacy policy.', ) */ ); } ?> == On 12 July 2010 14:39, McBuck DGAF wrote: > Instead of: > >> 'rule' => array('custom' => >> '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$'), > > Could you try: > > 'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)* > $', > > If that works, and you use this regular expression more than once, you > could consider implementing a custom validation rule as described > here: > > http://book.cakephp.org/view/1179/Custom-Validation-Rules > > > On Jul 11, 5:41 pm, Felix wrote: >> Hi, I have an odd validation issue I can't work out. > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Validation problem
Instead of: >'rule' => array('custom' => > '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$'), Could you try: 'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)* $', If that works, and you use this regular expression more than once, you could consider implementing a custom validation rule as described here: http://book.cakephp.org/view/1179/Custom-Validation-Rules On Jul 11, 5:41 pm, Felix wrote: > Hi, I have an odd validation issue I can't work out. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Validation problem
Hi, I have an odd validation issue I can't work out. I have the following form built using the form helper; == Form->create('Account');?> Form->input('username', array('id' => 'global_accounts_Username', 'div' => 'v input', 'label' => array('text' => 'Username', 'class' => 'label'))); ?> Can be any length but only contain letters and numbers. No spaces, hyphens or underscores allowed. Form->input('password', array('id' => 'global_accounts_Password', 'div' => 'v input', 'label' => array('text' => 'Password', 'class' => 'label'), 'after' => 'Time needed to crack password, ')); ?> Can contain any type of character but must be over 6 characters in length. It is recommended to use punctuation or a full sentence. Form->input('email', array('id' => 'global_accounts_Email', 'div' => 'v input', 'label' => array('text' => 'E-mail', 'class' => 'label'))); ?> Must exist and be accessible, a conformation e-mail will be sent to this address as well as any account notifications. Form->input('first_name', array('id' => 'global_accounts_FirstName', 'div' => 'v input', 'label' => array('text' => 'First name', 'class' => 'label'))); ?> If you are an individual please enter your first name, only letters are allowed. Form->input('second_name', array('id' => 'global_accounts_SecondName', 'div' => 'v input', 'label' => array('text' => 'Second name', 'class' => 'label'))); ?> If you are an individual please enter your second name, only letters are allowed. Form->input('company_name', array('id' => 'global_accounts_CompanyName', 'div' => 'v input', 'label' => array('text' => 'Company name', 'class' => 'label'))); ?> If you are a business please enter your business name, only letters, numbers and spaces are allowed. Form->input('terms_accepted', array('id' => 'global_accounts_TermsAccepted', 'div' => 'v input', 'label' => array('text' => 'Accept terms', 'class' => 'label_left'))); ?> To open an account you MUST agree to these terms and conditions and Privacy policy Form->end(__('Register account', true));?> == This is validated by the following validation rules in the 'Account' model. == var $validate = array( 'username' => array( 'rule' => 'alphaNumeric', 'message' => 'Usernames can only contain letters and numbers.', 'allowEmpty' => false ), 'password' => array( 'rule' => array('minlength', 6), 'message' => 'Passwords must be six (6) characters or more.', 'allowEmpty' => false ), 'email' => array( 'rule' => 'email', 'message' => 'Email must be valid.', 'allowEmpty' => false ), 'first_name' => array( 'rule' => array('custom' => '^[a-zA-Z]+(([\'\,\.\-][a- zA-Z])?[a-zA-Z]*)*$'), 'message' => 'Names can only contain letters.', 'allowEmpty' => false ), 'second_name' => array( 'rule' => array('custom' => '^[a-zA-Z]+(([\'\,\.\-][a- zA-Z])?[a-zA-Z]*)*$'), 'message' => 'Names can only contain letters.', 'allowEmpty' => false ), 'company_name' => array( 'rule' => array('custom' => '(\w(\s)?)+'), 'message' => 'Company names can only contain letters, numbers and spaces.' ), 'terms_accepted' => array( 'rule' => array('comparison', '!=', '>0'), 'required' => true, 'message' => 'You must agree to the terms and conditions and privacy policy.', 'on' => 'create' ) ); == The problem is whenever the form is submitted I get this error back; == Notice (8): Undefined offset: 0 [CORE/cake/libs/model/model.php, line 2550] Warning (512): Could not find validation handler for first_name [CORE/ cake/libs/model/model.php, line 2573] Warning (512): Could not find validation handler for second_name [CORE/cake/libs/model/model.php, line 2573] Warning (512): Could not find validation handler for company_name [CORE/cake/libs/model/model.php, line 2573] == I don't know why it doesn't like these fields, they are named the same in the database, form and validation rule let it doesn't seem to like it. The data is saved correctly to the database when supplied so that isn't an issue. Does anyone know a way around this? Thanks, Felix Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit th
Re: Validation problem
I would do something like this: items_controller.php function foo(){ if (!empty($this->data)) { //check if there is data sent if($this->User->field('email', array('conditions' => array('email' => $this->data['User']['email']{ //find the emai in the database } else { //email not found //your requestAction call } } } On 10 February 2010 01:09, dtirer wrote: > I have a form with an 'Item' and 'email' field. It submits to an > Items Controller. > I want to validate both fields, however, the 'email' is technically > part of a User model. > > So what happens is, when the form is submitted, it's supposed to > search for the Item in the form. it also check if the email is > already in the DB, and if it isn't it does a requestAction to the > UsersController, and runs the email through the signup() function, and > then goes back to finishing the Items Controler work. > > So how do I go about validating the Email field? > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Validation problem
I have a form with an 'Item' and 'email' field. It submits to an Items Controller. I want to validate both fields, however, the 'email' is technically part of a User model. So what happens is, when the form is submitted, it's supposed to search for the Item in the form. it also check if the email is already in the DB, and if it isn't it does a requestAction to the UsersController, and runs the email through the signup() function, and then goes back to finishing the Items Controler work. So how do I go about validating the Email field? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: E-mail address validation problem + patch
Thank you for your work, Veres-Szentkiralya Andras. Although I do not work with the Cake team, I do know that sending this to the Google Group isn't the proper place to submit change requests, and may go unseen by the developers. To submit bug reports/patches/fixes, you would want to use their current ticket/repository system located (I believe) at Lighthouse: http://cakephp.lighthouseapp.com/home On Jan 26, 11:31 pm, "Veres-Szentkiralyi Andras" wrote: > Hi, > the e-mail address validator in CakePHP considers addresses in the form of > f...@bar.com invalid because of the regular expression used for this purpose > in cake/libs/validation.php. Although RFC 5322 specifies that the local-part > of an e-mail address cannot end with a dot, some providers (e.g. freemail.hu, > with 3 million mailboxes) allow users to get and use such e-mail addresses. > > From a technical viewpoint I agree that such addresses shouldn't be allowed to > be used, but saying "go away, leave our beloved RFC alone" to every user who > visits a CakePHP-based webshop or other website is not a solution either. > > I attached a patch, which fixes this particular problem, consider applying it. > > -- > Veres-Szentkirályi András > > 0001-Fixing-the-e-mail-validation-regexp-foo.-bar.com.patch > < 1KViewDownload Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
E-mail address validation problem + patch
Hi, the e-mail address validator in CakePHP considers addresses in the form of f...@bar.com invalid because of the regular expression used for this purpose in cake/libs/validation.php. Although RFC 5322 specifies that the local-part of an e-mail address cannot end with a dot, some providers (e.g. freemail.hu, with 3 million mailboxes) allow users to get and use such e-mail addresses. >From a technical viewpoint I agree that such addresses shouldn't be allowed to be used, but saying "go away, leave our beloved RFC alone" to every user who visits a CakePHP-based webshop or other website is not a solution either. I attached a patch, which fixes this particular problem, consider applying it. -- Veres-Szentkirályi András Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en From 52c9e17a1ef837b6c850c7f61edc7ed37604692c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Wed, 27 Jan 2010 05:02:27 +0100 Subject: [PATCH] Fixing the e-mail validation regexp (f...@bar.com) --- cake/libs/validation.php |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/cake/libs/validation.php b/cake/libs/validation.php index 20324dd..4a887a8 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -387,7 +387,7 @@ class Validation extends Object { } if (is_null($regex)) { - $regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$__pattern['hostname'] . '$/i'; + $regex = '/^[\.a-z0-9!#$%&\'*+\/=?^_`{|}~-]+@' . self::$__pattern['hostname'] . '$/i'; } $return = self::_check($check, $regex); if ($deep === false || $deep === null) { -- 1.6.5
Re: Validation problem wtih "required" flag set
When cake validates fields it first checks for field existence in data array. If there is no such key, with required=true cake invalidate it, with required=false cake skip it. So this flag behave exactly as it is named. If field is required it must be present in data array. On Dec 24, 1:21 am, Philip wrote: > Hi all, > > I have been reading posts on the confusion over "required" flag and I > think I understand it pretty well. > > However I am having problem trying to make it work. > > For example, here is my call: > > $this->User->validate(array('User'=>array('username'=>'test'))); > > And for the model, I have just one rule, which is "notEmpty" with > "required" set to "true". > > Odd thing is that if I use a html FORM to post ($this->User->validate > ($_POST['data']), then it works, but not when I invoke it directly. > > I am wondering if this has anything to do with the way I structure the > data array? > > Any ideas would be appreciated, many thanks in advance. > > Philip Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Validation problem wtih "required" flag set
Hi all, I have been reading posts on the confusion over "required" flag and I think I understand it pretty well. However I am having problem trying to make it work. For example, here is my call: $this->User->validate(array('User'=>array('username'=>'test'))); And for the model, I have just one rule, which is "notEmpty" with "required" set to "true". Odd thing is that if I use a html FORM to post ($this->User->validate ($_POST['data']), then it works, but not when I invoke it directly. I am wondering if this has anything to do with the way I structure the data array? Any ideas would be appreciated, many thanks in advance. Philip Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: unique validation problem
On Thu, Sep 10, 2009 at 5:09 AM, Dr. Loboto wrote: > > Cake's "isUnique" method handles create & update situations well (so > you do not need "on" => "create" at all). Are you sure that you make > update? It is the common error - do not provide ID to model when want > update and it makes create instead. And do not "respect" the key "on" > of course because it makes create actually. > Sorry, I forgot to reply earlier. The problem was all mine. I'd included the ID but it was for the wrong model (cut & paste) so, as expected, Cake treated it like create. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: unique validation problem
Cake's "isUnique" method handles create & update situations well (so you do not need "on" => "create" at all). Are you sure that you make update? It is the common error - do not provide ID to model when want update and it makes create instead. And do not "respect" the key "on" of course because it makes create actually. On Sep 10, 12:50 am, brian wrote: > On Wed, Sep 9, 2009 at 1:42 PM, brian wrote: > > I have the following validatio rules: > > > 'email' => array( > > 'valid' => array( > > 'rule' => 'email', > > 'required' => true, > > 'allowEmpty' => false, > > 'message' => 'You must provide an email address.' > > ), > > 'duplicate' => array( > > 'rule' => 'isUnique', > > 'on' => 'create', > > 'message' => 'This email address is already registered with > > us. > > Because members use this as their login, the address must be unique.' > > ) > > ) > > > When editing a profile, I keep getting the 'duplicate' error msg. Am I > > using the 'on' param correctly? Is there something else necessary? > > Looking around online, there are scads of user-provided methods--some > > I've used myself--but my interpretation of isUnique was that it's > > enitrely built-in to Cake. > > I mean to add that Cake's query is: > > SELECT COUNT(*) AS `count` FROM `users` AS `Student` WHERE > `Student`.`email` = '@bar.net' > > I'd have though it would include "AND Student.id != ..." That would > seem more efficient than checking for the id in the result. But I > can't even locate where the code that handles this is. I've looked > through Validation class but I'm not seeing it. > > In any case, it shouldn't even be firing on an edit! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: unique validation problem
On Wed, Sep 9, 2009 at 1:42 PM, brian wrote: > I have the following validatio rules: > > 'email' => array( > 'valid' => array( > 'rule' => 'email', > 'required' => true, > 'allowEmpty' => false, > 'message' => 'You must provide an email address.' > ), > 'duplicate' => array( > 'rule' => 'isUnique', > 'on' => 'create', > 'message' => 'This email address is already registered with us. > Because members use this as their login, the address must be unique.' > ) > ) > > When editing a profile, I keep getting the 'duplicate' error msg. Am I > using the 'on' param correctly? Is there something else necessary? > Looking around online, there are scads of user-provided methods--some > I've used myself--but my interpretation of isUnique was that it's > enitrely built-in to Cake. > I mean to add that Cake's query is: SELECT COUNT(*) AS `count` FROM `users` AS `Student` WHERE `Student`.`email` = 'f...@bar.net' I'd have though it would include "AND Student.id != ..." That would seem more efficient than checking for the id in the result. But I can't even locate where the code that handles this is. I've looked through Validation class but I'm not seeing it. In any case, it shouldn't even be firing on an edit! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
unique validation problem
I have the following validatio rules: 'email' => array( 'valid' => array( 'rule' => 'email', 'required' => true, 'allowEmpty' => false, 'message' => 'You must provide an email address.' ), 'duplicate' => array( 'rule' => 'isUnique', 'on' => 'create', 'message' => 'This email address is already registered with us. Because members use this as their login, the address must be unique.' ) ) When editing a profile, I keep getting the 'duplicate' error msg. Am I using the 'on' param correctly? Is there something else necessary? Looking around online, there are scads of user-provided methods--some I've used myself--but my interpretation of isUnique was that it's enitrely built-in to Cake. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Regex validation problem.
The best human name validation - not empty one. On Sep 1, 9:29 pm, Bryan Paddock wrote: > Ah in the end I removed the validation completely... realized that putting > such restrictions on names is not the best idea (eg unicode chinese/jap > names etc) > > > > On Mon, Aug 31, 2009 at 5:14 PM, Dr. Loboto wrote: > > > Your function does all right - alphanumeric values only as you did > > nothing with it. > > > '/^[a-zA-Z0-9_-]+$/' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Regex validation problem.
Ah in the end I removed the validation completely... realized that putting such restrictions on names is not the best idea (eg unicode chinese/jap names etc) On Mon, Aug 31, 2009 at 5:14 PM, Dr. Loboto wrote: > > Your function does all right - alphanumeric values only as you did > nothing with it. > > '/^[a-zA-Z0-9_-]+$/' > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Regex validation problem.
Your function does all right - alphanumeric values only as you did nothing with it. '/^[a-zA-Z0-9_-]+$/' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Regex validation problem.
Hey guys, Having a weird problem here... In my validation everything was working fine except now I needed to change the first + surname validation fields to allow for spaces + dashes. It was originally just working on only alphanumeric characters. The dashes + underscores was an extra addition added now. Here is the first name section of the $this->validation variable: (copied directly from the cakephp book even...) *// First name:* *// - cannot be empty* *// - must be alphanumeric* * * *'name_first' => array(* * 'name_first-1' => array(* *'rule' => 'alphaNumericDashUnderscore',* *'message'=> 'First name can only contain alphanumeric characters and dashes'* * ),* * * * 'name_first-2' => array(* *'rule' => 'notEmpty',* *'message' => 'Please enter your firstname'* * )* *)* and I have the function: * function alphaNumericDashUnderscore($data)* * {* *$value = array_values($data);* *$value = $value[0];* ** *return preg_match('/^[a-zA-Z0-9]+$/', $value);* * }* Yet the validation still comes back as a failure each time... I can't figure this out... it should be rather simple but I just can't get it... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: data validation problem with multiple parameters
> Just a guess, but are you passing the auto-generated password to the > view when validation fails, so that it can be used in your form's > action attribute when re-POSTing another attempt at a new password? I don't think so. I am not doing anything. I am new to cakePHP. How do I do that? here is the section of my resetPassword method that is used: if(!empty($this->data)) { $this->Person->set($this->data); if($this->Person->validates()) { $this->Person->saveField('has_reset_password', '1'); $this->Person->saveField('password', $this->data ['Person']['password']); $this->Session->setFlash(__('Password has been saved', true)); $this->redirect(array('action'=>'index')); } } As you can see, if the data isnt valid, it drops out of this section of code, and in fact, out of the method. When this happens, the page redisplays which fields are invalid but the address no longer contains the password. I am guessing this is some auto feature of cakePHP. How do I make sure my view gets both parameters after validating the data? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: data validation problem with multiple parameters
On Mar 25, 3:41 pm, dubiousandrew wrote: > If I enter an invalid password on the form, then it does validate it > correctly and displays the error message but the new address becomes: > example.com/user/resetPassword/45 > and it truncates the password parameter and then it no longer > functions like it should. Just a guess, but are you passing the auto-generated password to the view when validation fails, so that it can be used in your form's action attribute when re-POSTing another attempt at a new password? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
data validation problem with multiple parameters
I have an edit form that takes in two parameters, an id of the user and user password. It is designed for the first time log in so the user is forced to create a password after following a link (that contains the automatically generated password and their id). For example: example.com/user/resetPassword/45/password (where the user id is '45' and the password is 'password') If I enter an invalid password on the form, then it does validate it correctly and displays the error message but the new address becomes: example.com/user/resetPassword/45 and it truncates the password parameter and then it no longer functions like it should. Can some one help me please? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: validation problem
On Sat, Mar 14, 2009 at 6:32 AM, kaushik wrote: > > I do not want to save the data, I want just if user has entered any > valid data, the valid data should not be entered again, they should > remain in the input box and invalid field will be blank with error > massage. Now he has to entry all the data again. If you don't remove or change $this->data then the form should be re-filled by FormHelper when that view is displayed again. function yourAction() { if (!empty($this->data)) { /* only reach here 2nd time through */ if ($this->YourModel->validates) { if ($this->YourModel->save($this->data) { ... /* you will not reach here if validation failed */ $this->redirect(...); } } } // display the form ... } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: validation problem
I do not want to save the data, I want just if user has entered any valid data, the valid data should not be entered again, they should remain in the input box and invalid field will be blank with error massage. Now he has to entry all the data again. On Mar 13, 1:33 pm, ShuXun Liu wrote: > Try use the third param in Save action. > like this: > > $this->User->save( $this->data, // make sure there is a "id" in data > array > true, > array('email') //just save email > ) > > 2009/3/13 kaushik > > > > > I have validate different field using cakephp's in-bulit validation > > system. but now problem is that the system does not persist all the > > values even if they are valid, e.g in a form, i have to give name, > > email, state, and the value given in email is not valid, but other > > values given in the field is valid. But when the system is reloading > > the form with the error massage, all the fields are blanks. I want to > > persist the valid values so that the user has to enter just invalid > > data. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: validation problem
Try use the third param in Save action. like this: $this->User->save( $this->data, // make sure there is a "id" in data array true, array('email') //just save email ) 2009/3/13 kaushik > > I have validate different field using cakephp's in-bulit validation > system. but now problem is that the system does not persist all the > values even if they are valid, e.g in a form, i have to give name, > email, state, and the value given in email is not valid, but other > values given in the field is valid. But when the system is reloading > the form with the error massage, all the fields are blanks. I want to > persist the valid values so that the user has to enter just invalid > data. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
validation problem
I have validate different field using cakephp's in-bulit validation system. but now problem is that the system does not persist all the values even if they are valid, e.g in a form, i have to give name, email, state, and the value given in email is not valid, but other values given in the field is valid. But when the system is reloading the form with the error massage, all the fields are blanks. I want to persist the valid values so that the user has to enter just invalid data. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation Problem
Take a look at the MultivalidateableBehavior in the bakery. That's what I used to solve your kind of problems. http://bakery.cakephp.org/articles/view/multivalidatablebehavior-using-many-validation-rulesets-per-model --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation Problem
You can use 'on' => 'create' or 'on' => 'update' to gain a finer grain of control. You can also set 'allowEmpty' => true for some fields. See here: http://teknoid.wordpress.com/2008/06/09/15-essential-cakephp-tips/ http://lemoncake.wordpress.com/2007/07/03/all-about-validation-in-cakephp-12/ On Mon, Mar 2, 2009 at 1:07 AM, akmjahan...@gmail.com wrote: > > I am facing a problem about validation. In my user model there are 20 > validation for registration form. During registration validation works > properly. But when any other action (i.e. update profile) under user > controller there are only 8 fields to check validation from user model > but it get failed. In this case when I removed others validation rule > (from all 20) i.e. 12 out of 20 (only 8 from update profile action) > then update profile action works. But I need all 20 rules within user > model. Is there anyone to help me ? > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Validation Problem
I am facing a problem about validation. In my user model there are 20 validation for registration form. During registration validation works properly. But when any other action (i.e. update profile) under user controller there are only 8 fields to check validation from user model but it get failed. In this case when I removed others validation rule (from all 20) i.e. 12 out of 20 (only 8 from update profile action) then update profile action works. But I need all 20 rules within user model. Is there anyone to help me ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation problem
Be careful using the alphaNumeric and money validation rules as they require UTF-8 support for PCRE. On a stock Centos 5 install (or Redhat ES5) I have PCRE 6.6 06-Feb-2006 compiled in.The following script fails (the alphaNumeric test from CakePHP 1.2 validation.php): If you don't need UTF-8 alphaNumeric support I recommend a simpler match expression: /^[A-Z0-9]+$/ --Dave Oribium wrote: > > > I am taking a look at cake 1.2, and I run into problems with the > validation > of form data. I took advantage of the console application to bake some > views, a model, and a controller based on an existing MySQL-database. > I > don't yet have a deep understanding of cake, and would happily welcome > hints and pointers which direction I should go. > > I am trying to post data from a form to a database. However, whatever > data > I post, I get redirected back to the form, where a label "This field > cannot > be left blank" is attached to all fields. For instance if I fill the > alphanumeric field "last_name" with "Jones" (without qoutes), I will > get > the error message: "This field cannot be left blank". Futhermore, > $this->validationErrors contains all fields and the same error > message. I > have verified that the correct data from the form are assigned to the > controller object's data array with Configure::write('debug', 3); > > The view is just a simple form like: > > echo $form->create('Lead'); > echo $form->input('last_name'); > echo $form->input('modified_user_id'); > ... quite a few more fields here ... > echo $form->end('Submit'); > > There are also a few form fields added with pure html code. These > fields > are not supposed to be posted to the database, neither be validated > with > the standard cake validation feature. > > In the model, there is nothing but "name" and the validation array. > > The model's validation array looks like: > > var $validate = array( > 'last_name' => array('alphanumeric'), > 'modified_user_id' => array('alphanumeric'), > --- quite a few more fields here --- > ) > > The controller's add function: > > function add() { > if (!empty($this->data)) { > if ($this->RequestHandler->isPost()) { > $this->Lead->create(); > $this->Lead->set($this->data); > if ($this->Lead->save($this->data)) { > $this->Session->setFlash(__('The Lead has been saved', true)); > $this->redirect(array('action'=>'index')); > } else { > $this->Session->setFlash(__('The Lead could not be saved. Please, try > again.', true)); > } > } > } > } > > I also tried the following code in the controller: if > ($this->Lead->validates()) with the same result. > > PHP version: 5.1.6 > OS: Linux > > CakePHP version: > $Id: VERSION.txt 7692 2008-10-02 05:06:48Z nate $ > > libs/model/model.php version: > $Id: model.php 7690 2008-10-02 04:56:53Z nate $ > > > > > -- View this message in context: http://www.nabble.com/Validation-problem-tp21051012p21315909.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation problem
Hi Oribium, I have had this problem. "This field cannot be left blank" is Cake's default response when the data you are saving does not meet your data structure and you haven't configured a validation message for the validation scenario. For example: if you specify a max field length of 3 characters, then try to save a string of 3 or more, you get the "This field cannot be left blank" response (if you haven't configured a validation rule in your Model). Additionally, it seems the message does not necessarily appear on the field which is having the issue. To fix it, try constructing a query to save the data that is causing the issue. When you identify the problematic data, add a validation rule into your model to catch it and return a more meaningful validation message. Cheers Paul. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation problem
Thank you for you reply, Rob. I simplified things trying to get the troubleshooting more easy. I created a model, and a view with only one field, "first_name". I also created an add function in the controller which is supposed to validate input rather then saving data to the database. The problem remains and I get redirected back to the form, where a label "Valid characters: letters and numbers only, please try again" is attached to the field. The view: create('Lead');?> input('first_name'); ?> end('Submit'); pr($this->validationErrors); pr($session); ?> The model: array( 'alphaNumeric' => array( 'rule' => 'alphaNumeric', 'required' => true, 'message' => 'Valid characters: letters and numbers only, please try again.' ))); } ?> The add function in the controller: function add() { if (!empty($this->data)) { if ($this->RequestHandler->isPost()) { $this->Lead->create(); $this->Lead->set($this->data); Debugger::dump($this->data['Lead']); Debugger::dump($this->Lead->validationErrors); Debugger::dump($this->Lead->invalidFields()); Debugger::dump($this->Lead->validate); if ($this->Lead->validates()) { $this->_sendMail(); $this->Session->setFlash(__('The Lead has been saved', true)); $this->redirect(array('action'=>'index')); } else { $this->Session->setFlash(__('The Lead could not be saved. Please, try again.', true)); } } } } Output from the Debugger statements in the add function: array( "first_name" => "Paul" ) array() array( "first_name" => "Valid characters: letters and numbers only, please try again." ) array( "first_name" => array() ) Dump of the SessionHelper Object: SessionHelper Object ( [helpers] => [__active] => 1 [valid] => [error] => [_userAgent] => 372acfb5aa1873a6a6ce218959a07d36 [path] => / [lastError] => [security] => [time] => 1229549419 [sessionTime] => [watchKeys] => Array ( ) [id] => [_log] => [base] => /somepath [webroot] => /somepath/ [here] => /somepath/leads/add [params] => Array ( [pass] => Array ( ) [named] => Array ( ) [controller] => leads [action] => add [plugin] => [form] => Array ( ) [data] => Array ( [Lead] => Array ( [first_name] => Paul ) ) [url] => Array ( [url] => leads/add ) [isAjax] => [models] => Array ( [0] => Lead ) ) [action] => add [data] => Array ( [Lead] => Array ( [first_name] => Paul ) ) [themeWeb] => [plugin] => [validationErrors] => Array ( [Lead] => Array ( [first_name] => Valid characters: letters and numbers only, please try again. ) ) ) On 17 Dec, 20:03, Rob wrote: > Without looking at your data model, I can't say for sure, but it would > seem like you may be breaking a rule that is implied by the table. > > That said, you might want to add a message to your $validate like: > > 'last_name' => array( > 'alphaNumeric' => array( > 'rule' => 'alphanumeric', > 'message' => 'Only letters and numbers for last > name, please try again.' > ), > ) > > On Dec 17, 2:56 am, Oribium wrote: > > > I am taking a look at cake 1.2, and I run into problems with the > > validation > > of form data. I took advantage of the console application to bake some > > views, a model, and a controller based on an existing MySQL-database. > > I > > don't yet have a deep understanding of cake, and would happily welcome > > hints and pointers which direction I should go. > > > I am trying to post data from a form to a database. However, whatever > > data > > I post, I get redirected back to the form, where a label "This field > > cannot > > be left blank" is attached to all fields. For instance if I fill the > > alphanumeric field "last_name" with "Jones" (wi
Re: Validation problem
Without looking at your data model, I can't say for sure, but it would seem like you may be breaking a rule that is implied by the table. That said, you might want to add a message to your $validate like: 'last_name' => array( 'alphaNumeric' => array( 'rule' => 'alphanumeric', 'message' => 'Only letters and numbers for last name, please try again.' ), ) On Dec 17, 2:56 am, Oribium wrote: > I am taking a look at cake 1.2, and I run into problems with the > validation > of form data. I took advantage of the console application to bake some > views, a model, and a controller based on an existing MySQL-database. > I > don't yet have a deep understanding of cake, and would happily welcome > hints and pointers which direction I should go. > > I am trying to post data from a form to a database. However, whatever > data > I post, I get redirected back to the form, where a label "This field > cannot > be left blank" is attached to all fields. For instance if I fill the > alphanumeric field "last_name" with "Jones" (without qoutes), I will > get > the error message: "This field cannot be left blank". Futhermore, > $this->validationErrors contains all fields and the same error > message. I > have verified that the correct data from the form are assigned to the > controller object's data array with Configure::write('debug', 3); > > The view is just a simple form like: > > echo $form->create('Lead'); > echo $form->input('last_name'); > echo $form->input('modified_user_id'); > ... quite a few more fields here ... > echo $form->end('Submit'); > > There are also a few form fields added with pure html code. These > fields > are not supposed to be posted to the database, neither be validated > with > the standard cake validation feature. > > In the model, there is nothing but "name" and the validation array. > > The model's validation array looks like: > > var $validate = array( > 'last_name' => array('alphanumeric'), > 'modified_user_id' => array('alphanumeric'), > --- quite a few more fields here --- > ) > > The controller's add function: > > function add() { > if (!empty($this->data)) { > if ($this->RequestHandler->isPost()) { > $this->Lead->create(); > $this->Lead->set($this->data); > if ($this->Lead->save($this->data)) { > $this->Session->setFlash(__('The Lead has been saved', true)); > $this->redirect(array('action'=>'index'));} else { > > $this->Session->setFlash(__('The Lead could not be saved. Please, try > again.', true)); > > } > } > } > } > > I also tried the following code in the controller: if > ($this->Lead->validates()) with the same result. > > PHP version: 5.1.6 > OS: Linux > > CakePHP version: > $Id: VERSION.txt 7692 2008-10-02 05:06:48Z nate $ > > libs/model/model.php version: > $Id: model.php 7690 2008-10-02 04:56:53Z nate $ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Validation problem
I am taking a look at cake 1.2, and I run into problems with the validation of form data. I took advantage of the console application to bake some views, a model, and a controller based on an existing MySQL-database. I don't yet have a deep understanding of cake, and would happily welcome hints and pointers which direction I should go. I am trying to post data from a form to a database. However, whatever data I post, I get redirected back to the form, where a label "This field cannot be left blank" is attached to all fields. For instance if I fill the alphanumeric field "last_name" with "Jones" (without qoutes), I will get the error message: "This field cannot be left blank". Futhermore, $this->validationErrors contains all fields and the same error message. I have verified that the correct data from the form are assigned to the controller object's data array with Configure::write('debug', 3); The view is just a simple form like: echo $form->create('Lead'); echo $form->input('last_name'); echo $form->input('modified_user_id'); ... quite a few more fields here ... echo $form->end('Submit'); There are also a few form fields added with pure html code. These fields are not supposed to be posted to the database, neither be validated with the standard cake validation feature. In the model, there is nothing but "name" and the validation array. The model's validation array looks like: var $validate = array( 'last_name' => array('alphanumeric'), 'modified_user_id' => array('alphanumeric'), --- quite a few more fields here --- ) The controller's add function: function add() { if (!empty($this->data)) { if ($this->RequestHandler->isPost()) { $this->Lead->create(); $this->Lead->set($this->data); if ($this->Lead->save($this->data)) { $this->Session->setFlash(__('The Lead has been saved', true)); $this->redirect(array('action'=>'index')); } else { $this->Session->setFlash(__('The Lead could not be saved. Please, try again.', true)); } } } } I also tried the following code in the controller: if ($this->Lead->validates()) with the same result. PHP version: 5.1.6 OS: Linux CakePHP version: $Id: VERSION.txt 7692 2008-10-02 05:06:48Z nate $ libs/model/model.php version: $Id: model.php 7690 2008-10-02 04:56:53Z nate $ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: multiple email validation problem
Or you could write it into a custom function. Then call your custom function for each of the email fields. Ie. 'email1' => array ('customFunction'), 'email2' => etc... You do have to assign a validation to rule to each individual form element by name, in your case email1, email2 and email3. Granted one element can have multiple rules. On Dec 3, 7:57 am, rgreenphotodesign <[EMAIL PROTECTED]> wrote: > each form field will need it's own validation rule. > > What you have should work, just change the name to email1, then cut/ > paste the whole rule and rename email2 etc. > > You could probably write something on the beforeValidates that renames > your variables to "email", validates them, but then you'd have to get > them back to their original variable names (email1 etc) to save in the > DB. I assume you have 3 columns in your database? email1, email2 etc? > > On Dec 2, 9:27 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > Hi there, > > i got a problem with cake, i m using the lastest version. > > > i got a form with 3 email fields. email1, email2, email3. > > and in my table, i want to record each email. > > > i tried to make a validation rule for email. > > > i got : > > > var $validate = array( > > 'email' => array( > > 'valid' => array( > > > > 'rule' => 'email', > > > > 'message' => 'Please enter a valid email address' > > ), > > 'unique' => > > array( > > > > 'rule' => 'isUnique', > > > > 'message' => 'This email address has already been used' > > ) > > )); > > > but it' doesn"t work at all. i think there's a problem with the name > > of my form fields and the validation. > > > any idea ? > > > thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: multiple email validation problem
each form field will need it's own validation rule. What you have should work, just change the name to email1, then cut/ paste the whole rule and rename email2 etc. You could probably write something on the beforeValidates that renames your variables to "email", validates them, but then you'd have to get them back to their original variable names (email1 etc) to save in the DB. I assume you have 3 columns in your database? email1, email2 etc? On Dec 2, 9:27 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi there, > i got a problem with cake, i m using the lastest version. > > i got a form with 3 email fields. email1, email2, email3. > and in my table, i want to record each email. > > i tried to make a validation rule for email. > > i got : > > var $validate = array( > 'email' => array( > 'valid' => array( > > 'rule' => 'email', > > 'message' => 'Please enter a valid email address' > ), > 'unique' => > array( > > 'rule' => 'isUnique', > > 'message' => 'This email address has already been used' > ) > )); > > but it' doesn"t work at all. i think there's a problem with the name > of my form fields and the validation. > > any idea ? > > thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
multiple email validation problem
Hi there, i got a problem with cake, i m using the lastest version. i got a form with 3 email fields. email1, email2, email3. and in my table, i want to record each email. i tried to make a validation rule for email. i got : var $validate = array( 'email' => array( 'valid' => array( 'rule' => 'email', 'message' => 'Please enter a valid email address' ), 'unique' => array( 'rule' => 'isUnique', 'message' => 'This email address has already been used' ) )); but it' doesn"t work at all. i think there's a problem with the name of my form fields and the validation. any idea ? thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: validation problem
Have you tried specifying the rule as an array as per the docs? http://manual.cakephp.org/view/141/email ... 'rule' => array('email', true) On Jul 4, 10:48 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > is try to validate an emailadres, my fieldname is 'email'. > > The code looks like this: > > var $validate = array( > 'email' => array( > 'rule' => 'email', > 'message' => 'Please enter valid emailadres' > ) > ); > > I doesn't trigger an error, not when left blank, or entering 'sldkjf'. > > What's my problem? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: validation problem
need no help anymore --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
validation problem
is try to validate an emailadres, my fieldname is 'email'. The code looks like this: var $validate = array( 'email' => array( 'rule' => 'email', 'message' => 'Please enter valid emailadres' ) ); I doesn't trigger an error, not when left blank, or entering 'sldkjf'. What's my problem? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Data validation problem
$this->Post->create($this->data); if ($this->Post->validates()) { // Data is good } else { // Data contains errors } On May 15, 9:21 pm, Wojtek <[EMAIL PROTECTED]> wrote: > I have a problem with validating data without saveing anything in > database. > For example this script work good > if ($this->Post->save($this->data)) { > $this->flash('blabla.','/posts'); > > } > > but when I use some my function form is not validating > if ($this->Post->myFunction($this->data)) { > $this->flash('blabla.','/posts'); > > } > > How can I manually use validating rules from model? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Data validation problem
I have a problem with validating data without saveing anything in database. For example this script work good if ($this->Post->save($this->data)) { $this->flash('blabla.','/posts'); } but when I use some my function form is not validating if ($this->Post->myFunction($this->data)) { $this->flash('blabla.','/posts'); } How can I manually use validating rules from model? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation problem in CakePHP 1.2
Never mind I found my answer! For those of you looking to get two password fields to validate, or having the same problem as me this form has your answers. Here's what was wrong: In the Controller this is what I had: //register function function register() { if (!empty($this->data)) { if ($this->data['User']['password'] == $this- >Auth->password($this- >data['User']['password_confirm'])) { $this->User->create(); $this->User->save($this->data); $this->Session->setFlash("You have been registered! You can log in now."); $this->redirect(array('action' => 'index')); } } } I checked out my original code and compared it, after comparing it I added this little snippet and now it works: //register function function register() { if (!empty($this->data)) { if ($this->data['User']['password'] == $this->Auth->password($this- >data['User']['password_confirm'])) { $this->User->create() && $this->User->validates(); if ($this->User->save($this->data)) { $this->Session->setFlash("You have been registered! You can log in now."); $this->redirect(array('action' => 'index')); } } } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation problem in CakePHP 1.2
Controller (where I suspect the problem is, most changes were made here): Auth->allow('register', 'top'); } //top users funciton function top() { $this->set('users', $this->User->findAll()); } //login function function login() { } //index function function index() { } //register function function register() { if (!empty($this->data)) { if ($this->data['User']['password'] == $this->Auth->password($this- >data['User']['password_confirm'])) { $this->User->create(); $this->User->save($this->data); $this->Session->setFlash("You have been registered! You can log in now."); $this->redirect(array('action' => 'index')); } } } } ?> Model: array( VALID_NOT_EMPTY, 'alphanumeric' => array( 'rule' => 'alphaNumeric', 'message' => 'Only alphabets and numbers allowed', ), 'maxlength' => array( 'rule' => array('maxLength', 50), 'message' => 'Username has a maximum length of 50 characters', ), 'required' => array( 'rule' => array('required' => true), 'message' => 'Username is required, how do you expect to log in?' ), 'isUnique' => array( 'rule' => array('isUnique', 'username'), 'message' => 'Hey! Lookey there, someone got to that username before you. Sorry, but you\'ll have to choose another.' ) ), //email validation 'email' => array( VALID_NOT_EMPTY, 'maxlength' => array( 'rule' => array('maxLength', 40), 'message' => 'Email has a maximum length of 40 characters.' ), 'email' => array( 'rule' => array('email', true), 'message' => 'Please supply a valid email address.' ), 'required' => array( 'rule' => array('required' => true), 'message' => 'Email is required.' ), 'isUnique' => array( 'rule' => array('isUnique', 'email'), 'message' => 'That email address has already been claimed by another... maybe even you, please try again. This time enter an email address not in use on this site ;-)' ) ), //first name validation 'first_name' => array( VALID_NOT_EMPTY, 'maxlength' => array( 'rule' => array('maxLength', 15), 'message' => 'First name has a maximum length of 15 characters', ), 'required' => array( 'rule' => array('required' => true), 'message' => 'First name is required, don\'t you want your friends to be able to find you?' ) ), //last name validation 'last_name' => array( VALID_NOT_EMPTY, 'maxlength' => array( 'rule' => array('maxLength', 30), 'message' => 'Last name has a maximum length of 30 characters' ), 'required' => array( 'rule' => array('required' => true), 'message' => 'Last name is required, don\'t you want your friends to be able to find you?' ) ), //password validation 'password' => array( 'passwordConfirm' => array( 'rule' => array('confirmPassword', 'password'), 'message' => 'passwords don\'t match up, please verify and submit again!' ) ), //confirm password 'confirm_password' => array( VALID_NOT_EMPTY, 'alphanumeric' => array( 'rule' => 'alphaNum
Validation problem in CakePHP 1.2
Hey everyone! I'm a major newb to CakePHP only been using it for 2 weeks now and I've run into a little trouble with some validation. I've got a user registration page that I'm trying to create finally got the check between passwords to work thanks to Chris Hartjes' tutorial on user registration on his blog http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/ Anyways, using his techniques also introduced something else I wasn't doing before using the Auth component. Which is great, I would of needed it anyways... problem is now if somebody does something wrong (puts in a duplicate username, passwords don't match, uses wrong characters for something, etc.) it displays my splash message "You've been registered! You can log in now." and redirects to the login page. Nothing has been added to the database because it didn't pass validation, but it also didn't go back to the /users/register page like it used to to display the errors. I've got to go to work for right now, but I'll come back and post my code so that you guys can take a look at it. I was just hoping that maybe someone knew what was going on and could help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation Problem
I'm a dough-head. Sorry, I didn't read your post correctly. But, would you really need to change the name f any countries? Those don't change too often. And when one did, I'd think you'd want to update the main DB record for it rather than the association to some other model. If what you want to do is to update the list of associated countries to your model, you could do: $form->select('Country.Country', $countries, null, array('class' => 'Required', 'multiple' => 'checkbox')); (note the double "Country"--that's important) This will create checkboxes for each country. I can't remember, offhand, how to make the associated ones checked (sorry). Your $countries var would be an array gotten from a find('list') call in the controller. Or, you could replace it with $this->requestAction('Countries/getList') if you had an appropriate controller/action for that. On Wed, Apr 23, 2008 at 1:57 PM, plinto <[EMAIL PROTECTED]> wrote: > > Thanks, I understand what you are saying but what I need is to be able > to edit mutliple items at once. > For example if I have to edit 20 countries, clicking on every one, > editing it and saving it would take me alot more time then selecting > the ones I need to edit and having them presented in 1 page to be > edited and saved. > I also need to validate them but, for example, being all > "Country.name" I don't know how to obtain this. > > For the part about the parser, Thanks! I'm pretty new to php and > cakephp, but willing to learn. > > > > On Apr 22, 6:49 pm, "b logica" <[EMAIL PROTECTED]> wrote: > > You might find it simpler to, instead creating a form, to put links > > around the country names pointing to an edit method. In the edit view, > > create one form to edit the table fields and one form to delete. So > > you have something like: > > > > Edit Canada > > > > echo $form->create('Country', array('action' => 'delete'); > > echo $form->hidden('Country.id', array('value' => $some_var)); > > echo $form->submit('delete'); > > echo $form->end(); > > > > echo $form->create('Country', array('action' => 'edit'); > > ... > > echo $form->submit('edit'); > > echo $form->end(); > > > > This way, each action points directly to the corresponding method and > > you only have to deal with one item at a time. I realise that this may > > not be practical but it may work for you. > > > > Regarding $some_var above, your code appears to assume that the > > country IDs & names are going to line up with your counter var $i. I > > may be missing something but that looks odd to me. I'd think it's be > > better (if your $countries array is constructed as $id => $name) to do > > it with a while like so: > > > > foreach ($countries as $key => $name) > > { > >$html->link($name, "countries/edit/${id}"); > > > > } > > > > I've used my link suggestion but it's just as applicable to a form > > setup like you have. > > > > BTW, in your views, you don't need to put around every > > line. If you don't have any HTML markup to add then you can just open > > a block: > > > > > echo $form->create(array('url'=>'/countries/process')); > > > > for($i =0; $i<$countries; $i++) { > >echo $form->hidden('Country'.$i.'.Country.id'); > >echo $form->input('Country'.$i.'.Country.name'); > > > > } > > > > echo $form->submit('Save', array('name'=>'save')); > > echo $form->end(); > > ?> > > > > Otherwise, you're making the parser (and anyone who has to look at > > your code) work a lot harder than necessary ;-) > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation Problem
Thanks, I understand what you are saying but what I need is to be able to edit mutliple items at once. For example if I have to edit 20 countries, clicking on every one, editing it and saving it would take me alot more time then selecting the ones I need to edit and having them presented in 1 page to be edited and saved. I also need to validate them but, for example, being all "Country.name" I don't know how to obtain this. For the part about the parser, Thanks! I'm pretty new to php and cakephp, but willing to learn. On Apr 22, 6:49 pm, "b logica" <[EMAIL PROTECTED]> wrote: > You might find it simpler to, instead creating a form, to put links > around the country names pointing to an edit method. In the edit view, > create one form to edit the table fields and one form to delete. So > you have something like: > > Edit Canada > > echo $form->create('Country', array('action' => 'delete'); > echo $form->hidden('Country.id', array('value' => $some_var)); > echo $form->submit('delete'); > echo $form->end(); > > echo $form->create('Country', array('action' => 'edit'); > ... > echo $form->submit('edit'); > echo $form->end(); > > This way, each action points directly to the corresponding method and > you only have to deal with one item at a time. I realise that this may > not be practical but it may work for you. > > Regarding $some_var above, your code appears to assume that the > country IDs & names are going to line up with your counter var $i. I > may be missing something but that looks odd to me. I'd think it's be > better (if your $countries array is constructed as $id => $name) to do > it with a while like so: > > foreach ($countries as $key => $name) > { >$html->link($name, "countries/edit/${id}"); > > } > > I've used my link suggestion but it's just as applicable to a form > setup like you have. > > BTW, in your views, you don't need to put around every > line. If you don't have any HTML markup to add then you can just open > a block: > > echo $form->create(array('url'=>'/countries/process')); > > for($i =0; $i<$countries; $i++) { >echo $form->hidden('Country'.$i.'.Country.id'); >echo $form->input('Country'.$i.'.Country.name'); > > } > > echo $form->submit('Save', array('name'=>'save')); > echo $form->end(); > ?> > > Otherwise, you're making the parser (and anyone who has to look at > your code) work a lot harder than necessary ;-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation Problem
You might find it simpler to, instead creating a form, to put links around the country names pointing to an edit method. In the edit view, create one form to edit the table fields and one form to delete. So you have something like: Edit Canada echo $form->create('Country', array('action' => 'delete'); echo $form->hidden('Country.id', array('value' => $some_var)); echo $form->submit('delete'); echo $form->end(); echo $form->create('Country', array('action' => 'edit'); ... echo $form->submit('edit'); echo $form->end(); This way, each action points directly to the corresponding method and you only have to deal with one item at a time. I realise that this may not be practical but it may work for you. Regarding $some_var above, your code appears to assume that the country IDs & names are going to line up with your counter var $i. I may be missing something but that looks odd to me. I'd think it's be better (if your $countries array is constructed as $id => $name) to do it with a while like so: foreach ($countries as $key => $name) { $html->link($name, "countries/edit/${id}"); } I've used my link suggestion but it's just as applicable to a form setup like you have. BTW, in your views, you don't need to put around every line. If you don't have any HTML markup to add then you can just open a block: create(array('url'=>'/countries/process')); for($i =0; $i<$countries; $i++) { echo $form->hidden('Country'.$i.'.Country.id'); echo $form->input('Country'.$i.'.Country.name'); } echo $form->submit('Save', array('name'=>'save')); echo $form->end(); ?> Otherwise, you're making the parser (and anyone who has to look at your code) work a lot harder than necessary ;-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Validation Problem
Hello, I am making a table that is a form where every item added has a checkbox and the form has 2 submit buttons, 1 is to edit e 1 to delete. _ __|__ | Italy X | Us X | Canada __ | Edit | Delete | The problem I am having is, since you can edit more than 1 item, I don't know how to correctly validate them on the process view. Here is the code to what I have done. function process() { if ( !empty($this->params['form']['del']) ){ $this->delete(); } else if ( !empty($this->params['form']['edit']) ){ $this->edit(); } else if ( !empty($this->params['form']['save']) ){ $this->save(); } } function save() { if(!empty($this->data)) { foreach($this->data as $country): if ($this->Country->save($country)) {} endforeach; $this->redirect('/countries'); $this->Session->setFlash('Saved','default',null,'error'); } } function edit() { if (!empty($this->data)) { $i =0; foreach($this->data['Country'] as $id=>$value): if ($value == 1) { $this->Country->id = $id; $this->data['Country'.$i] = $this->Country->read(); $i++; } endforeach; if ($i == 0) { $this->Session->setFlash('Nothing Selected','default',null,'error'); $this->redirect('/countries'); } $this->set('countries', $i); } } process.ctp create(array('url'=>'/countries/process')); ?> hidden('Country'.$i.'.Country.id'); ?> input('Country'.$i.'.Country.name')?> submit('Save', array('name'=>'save')) ?> end(); ?> --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Form Data Validation problem...
This: class UserAppModel extends AppModel{ should be: class UserModel extends AppModel{ On Jan 30, 2008 8:04 PM, Pq2son2 <[EMAIL PROTECTED]> wrote: > > Hi, > > First Thanks, I'm a newbaby andI read a lot of manuals and the API but > I don't found the reason because the CakePHP (version 1.2.0.6311) > doesn't validate any parameter. Here I write the simple exemple that I > try for test the validation in this framework. > > Model: > class UserAppModel extends AppModel{ > var $name="User"; > > var $validate= array( > 'password' => array( > 'rule' => 'alphanumeric', > 'required' => true, > 'allowEmpty' => false, > 'message'=> 'Error!' > ) > ); > } > ?> > > > Controller: > > class UsersController extends AppController{ > var $name = "Users"; > var $helpers= array('Html','Form'); > > function index(){ > if(!empty($this->data)){ > $this->User->set($this->data); > if($this->User->validates()){ > echo "No hay ningun error"; > }else{ > echo "ERROR!!"; > } > } > } > } > ?> > > View: > create('User',array('action'=>'index'));?> > input('password');?> > error('User.password','Aixo no vaaa!! arg!!');?> > submit('Ok');?> > end();?> > > > It's really simply but doesn't work! and I don't know why, if any one > can found the problem and say it to me, really thanks. > > The bakery's that I read are: > - Validation with CakePHP 1.2: > http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/- > - Multiple Rules of Validation per... : > http://bakery.cakephp.org/articles/view/multiple-rules-of-validation-per-field-in-cakephp-1-2 > - CakePHP Manual: http://manual.cakephp.org/chapter/validation > - And others. really I don't understand how make it works. > > Thanks > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Form Data Validation problem...
Hi, First Thanks, I'm a newbaby andI read a lot of manuals and the API but I don't found the reason because the CakePHP (version 1.2.0.6311) doesn't validate any parameter. Here I write the simple exemple that I try for test the validation in this framework. Model: array( 'rule' => 'alphanumeric', 'required' => true, 'allowEmpty' => false, 'message'=> 'Error!' ) ); } ?> Controller: data)){ $this->User->set($this->data); if($this->User->validates()){ echo "No hay ningun error"; }else{ echo "ERROR!!"; } } } } ?> View: create('User',array('action'=>'index'));?> input('password');?> error('User.password','Aixo no vaaa!! arg!!');?> submit('Ok');?> end();?> It's really simply but doesn't work! and I don't know why, if any one can found the problem and say it to me, really thanks. The bakery's that I read are: - Validation with CakePHP 1.2: http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/- - Multiple Rules of Validation per... : http://bakery.cakephp.org/articles/view/multiple-rules-of-validation-per-field-in-cakephp-1-2 - CakePHP Manual: http://manual.cakephp.org/chapter/validation - And others. really I don't understand how make it works. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
$persistModel and model validation problem
I'm having a problem with $persistModel = true. I have two models: Subproduct hasMany Unavailability, and Unavailability belongsTo Subproduct. After a first request to /subproducts/search/ with an (intentionally) invalid parameter for 'from_date' in the search form, cake creates the Subproduct model object cache file, and displays the error correctly under the 'from_date' field in the search form. For all subsequent requests, no more errors show up under the 'from_date' field on the form when invalid data is entered. If I delete the cached model object file, errors show up again, but only for the first time because as soon as cake creates the cached object model file, the errors no longer show up. Note: there is only a cached model file created for Subproduct, but not for Unavailability. I narrowed down the problem to the following: when the code returns from the invalidate() function, the validationErrors array is being reset to null. Here is my call to the invalidate function. I call it from the subproducts controller: $this->Subproduct->Unavailability->invalidate('from_date'); Within the invalidate function, $this->validationErrors['from_date'] = 1. As soon as the function returns, $this->validationErrors = null. Any suggestions ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cake Bake and Validation Problem
Hello Recently I reported a bug ticket to the Cakephp Trac about this issue. I succeed reproducing the error under Windows and linux using the 1.1.17.5612 release and recent nightly builds too. So I think is a bug. If you want to follow the progress of the ticket please check [1] [1] https://trac.cakephp.org/ticket/3221 Regards, hmart On Sep 3, 5:03 am, red <[EMAIL PROTECTED]> wrote: > I have the same problem (look at "Release: 1.1.17.5612" thread). It > looks that is problem of this build, the previous one was good. > > On 3 Wrz, 08:50, "Gould, Adrian" <[EMAIL PROTECTED]> > wrote: > > > Anyone seen this problem before... > > > When using bake.php from the last build of CakePHP [Stable: 1.1.17.5612] I > > am getting a problem where the fields are not being displayed in the bake a > > model sequence when it comes to the validation, as shown at the end of this > > message. > > > I am running CakePHP on a Windows XP machine with XAMPP installed and > > configured correctly to suit CakePHP. > > > The files are being run directly from C:\Program > > Files\XAMPP\htdocs\GouldAJ\PIR\ using the command line: > > > php .\cake\scripts\bake.php > > > The php interpreter is in the PATH variable so that is running fine. > > > The resulting model file contains: > > > > class UserType extends AppModel { > > > var $name = 'UserType'; > > var $validate = array( > > '' => VALID_NOT_EMPTY, > > ); > > > } > > > ?> > > > which is not what I required (after answering all the questions correctly / > > interpreting what field was supposed to be displayed at the time). > > > Any ideas? > > > Many thanks in advance > > Adrian > > > --- text screen shot of the problem below --- > > > Would you like to supply validation criteria for the fields in your model? > > (y/n) > > > [y] > > > > Name: > > Type: integer > > --- > > Please select one of the following validation options: > > --- > > 1- VALID_NOT_EMPTY > > 2- VALID_EMAIL > > 3- VALID_NUMBER > > 4- VALID_YEAR > > 5- Do not do any validation on this field. > > > ... or enter in a valid regex validation string. > > > [1] > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cake Bake and Validation Problem
I have the same problem (look at "Release: 1.1.17.5612" thread). It looks that is problem of this build, the previous one was good. On 3 Wrz, 08:50, "Gould, Adrian" <[EMAIL PROTECTED]> wrote: > Anyone seen this problem before... > > When using bake.php from the last build of CakePHP [Stable: 1.1.17.5612] I am > getting a problem where the fields are not being displayed in the bake a > model sequence when it comes to the validation, as shown at the end of this > message. > > I am running CakePHP on a Windows XP machine with XAMPP installed and > configured correctly to suit CakePHP. > > The files are being run directly from C:\Program > Files\XAMPP\htdocs\GouldAJ\PIR\ using the command line: > > php .\cake\scripts\bake.php > > The php interpreter is in the PATH variable so that is running fine. > > The resulting model file contains: > > class UserType extends AppModel { > > var $name = 'UserType'; > var $validate = array( > '' => VALID_NOT_EMPTY, > ); > > } > > ?> > > which is not what I required (after answering all the questions correctly / > interpreting what field was supposed to be displayed at the time). > > Any ideas? > > Many thanks in advance > Adrian > > --- text screen shot of the problem below --- > > Would you like to supply validation criteria for the fields in your model? > (y/n) > > [y] > > > Name: > Type: integer > --- > Please select one of the following validation options: > --- > 1- VALID_NOT_EMPTY > 2- VALID_EMAIL > 3- VALID_NUMBER > 4- VALID_YEAR > 5- Do not do any validation on this field. > > ... or enter in a valid regex validation string. > > [1] > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Cake Bake and Validation Problem
Anyone seen this problem before... When using bake.php from the last build of CakePHP [Stable: 1.1.17.5612] I am getting a problem where the fields are not being displayed in the bake a model sequence when it comes to the validation, as shown at the end of this message. I am running CakePHP on a Windows XP machine with XAMPP installed and configured correctly to suit CakePHP. The files are being run directly from C:\Program Files\XAMPP\htdocs\GouldAJ\PIR\ using the command line: php .\cake\scripts\bake.php The php interpreter is in the PATH variable so that is running fine. The resulting model file contains: VALID_NOT_EMPTY, ); } ?> which is not what I required (after answering all the questions correctly / interpreting what field was supposed to be displayed at the time). Any ideas? Many thanks in advance Adrian --- text screen shot of the problem below --- Would you like to supply validation criteria for the fields in your model? (y/n) [y] > Name: Type: integer --- Please select one of the following validation options: --- 1- VALID_NOT_EMPTY 2- VALID_EMAIL 3- VALID_NUMBER 4- VALID_YEAR 5- Do not do any validation on this field. ... or enter in a valid regex validation string. [1] > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 Data Validation Problem
On 8/1/07, Pablo Viojo <[EMAIL PROTECTED]> wrote: > > Tryarray('rule' => array('alphaNumeric')) (note => instead of ,) Ah... that fix it. What a miss :P Thanks Pablo ! > > -- > Pablo Viojo > [EMAIL PROTECTED] > http://pviojo.net > > Regars, Feris http://www.phi-integration.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 Data Validation Problem
Tryarray('rule' => array('alphaNumeric')) (note => instead of ,) -- Pablo Viojo [EMAIL PROTECTED] http://pviojo.net On 8/1/07, Feris Thia <[EMAIL PROTECTED]> wrote: > > Hi All, > > I've read about data validation in CakePHP 1.2 version and I change my > model $validate var as below : > > > var $validate = array( > 'username' => array('rule', array('alphaNumeric')), > 'password' => array('rule', array('alphaNumeric')) > ); > > > and I test the validation with following code in my controller > > $data = array ( 'User' => array ( 'username' => > 'dfsdfjhjhg', 'password' => 'sdffsdfsdf') ); > $this->User->create($data); > if ($this->User->validates()) > { >echo 'succeed'; > } > > > But the code returns this warning : > > Warning (2): preg_match() [function.preg-match]: Delimiter must not be > alphanumeric or backslash [CORE\cake\libs\model\model.php, line 1674] > > What's wrong ? > > Regards, > > Feris > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Cake 1.2 Data Validation Problem
Hi All, I've read about data validation in CakePHP 1.2 version and I change my model $validate var as below : var $validate = array( 'username' => array('rule', array('alphaNumeric')), 'password' => array('rule', array('alphaNumeric')) ); and I test the validation with following code in my controller $data = array ( 'User' => array ( 'username' => 'dfsdfjhjhg', 'password' => 'sdffsdfsdf') ); $this->User->create($data); if ($this->User->validates()) { echo 'succeed'; } But the code returns this warning : Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE\cake\libs\model\model.php, line 1674] What's wrong ? Regards, Feris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Data validation problem
this is the code: /***MODEL***/ class Note extends AppModel { var $name = 'Note'; var $validate = array( 'title' => VALID_NOT_EMPTY, 'body' => VALID_NOT_EMPTY, ); } /VIEW***/ Add Note " method="post"> Title: input('Note/title', array('size' => '40'))?> tagErrorMsg('Note/title', 'Title is required.')? > Body: textarea('Note/body') ?> tagErrorMsg('Note/body', 'Title is required.')?> submit('Save') ?> /**Controller*/ class NotesController extends AppController { var $name = 'Notes'; var $uses = array('Note'); var $helpers = array('Html','Ajax','Form'); function index() { //$this->set('notes', $this->Note->findAll()); } function view($id) { $this->Note->id = $id; $this->set('data', $this->Note->read()); } function add () { if (empty($this->data)) { $this->render(); } else { if($this->Note->save($this->data)) { $this->flash('Your note has been updated.','/notes/'); } else { //Danger, Will Robinson. Validation errors. $this->set('errorMessage', 'Please correct errors below.'); $this->render(); } } } On 29 mar, 13:29, "savagekabbage" <[EMAIL PROTECTED]> wrote: > Do you have your model set up correctly to handle data validation? > > On Mar 29, 12:49 pm, "christianandradet" <[EMAIL PROTECTED]> > wrote: > > > > > hi i am trying to do the validation that this page > > teaches:http://manual.cakephp.org/chapter/validation > > it works but the messages do not appear: > > tagErrorMsg('Post/title', 'Title is required.')?> > > I do not know whatis the problem, maybe it's something that needs to > > be configured, > > Please help > > Thanks!- Ocultar texto de la cita - > > - Mostrar texto de la cita - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Data validation problem
On 3/29/07, christianandradet <[EMAIL PROTECTED]> wrote: > > > hi i am trying to do the validation that this page teaches: > http://manual.cakephp.org/chapter/validation > it works but the messages do not appear: > tagErrorMsg('Post/title', 'Title is required.')?> > I do not know whatis the problem, maybe it's something that needs to > be configured, > Hola Christian, What does your $validate array look like? (in post.php) Saludos/Regards, Gonzalo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Data validation problem
Do you have your model set up correctly to handle data validation? On Mar 29, 12:49 pm, "christianandradet" <[EMAIL PROTECTED]> wrote: > hi i am trying to do the validation that this page > teaches:http://manual.cakephp.org/chapter/validation > it works but the messages do not appear: > tagErrorMsg('Post/title', 'Title is required.')?> > I do not know whatis the problem, maybe it's something that needs to > be configured, > Please help > Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Data validation problem
hi i am trying to do the validation that this page teaches: http://manual.cakephp.org/chapter/validation it works but the messages do not appear: tagErrorMsg('Post/title', 'Title is required.')?> I do not know whatis the problem, maybe it's something that needs to be configured, Please help Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: validation problem with 1.2
Use $form->error() instead of $html->tagErrorMsg() in 1.2 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
validation problem with 1.2
Hello, I have a problem with $html->tagErrorMsg() and helper tagIsInvalid() functions. The tageErrorMsg function have an if : $error = 1; if ($error == $this->tagIsInvalid()) { but the tagIsInvalid() always return with a string if there is an error messag and never true this if. Is this a bug? Or I made some mistake? -- Ámon Tamás http://linkfelho.amon.hu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
SOLVED. Re: Validation problem with multiple select boxes
Well, I got it. Mea maxima culpa. In the controller, I was setting the select[Model] array with only one index. Instead of: if(empty($this->data['Model']['Model'])) { $this->data['Model'] ['Model'] = null; } $this->set('selectedModels', $this->data['Model']['Model']); I was trying: if(empty($this->data['Model'])) { $this->data['Model'] = null; } $this->set('selectedAreas', $this->data['Model']); This was bombing out at the _selectedArray method of the controller class. After some hours scattering var_dumps here and there, the problem became obvious. Hope with time and experience I start to get these kind of stupid mistakes faster. Or avoid them. Norman On 16 fev, 20:36, "Norman" <[EMAIL PROTECTED]> wrote: > Forget about my previous post, and my sincere apologies to Evan Sagge, > his fine piece of code have no connection with my misery. I "baked" > from ground up the models, controllers and views for the tables > involved and the vanilla CakePHP validation is presenting the same > behavior with multiple select listboxes. If any field does not > validate, the multiple selects loose their selected options. > > Norman > > On 16 fev, 20:06, "Norman" <[EMAIL PROTECTED]> wrote: > > > One thing I am sure about: This problem is not related with the > > "vanilla" CakePHP 1.1 validation. Im using "Evan's CakePHP Validation > > Technique 2.0" (http://blog.evansagge.com/2006/12/28/evans-cakephp- > > validation-technique-20/) and Im pretty sure theres a bug at the > > validation class causing this behavior with multiple select boxes. But > > I was not able to find it. > > > Norman > > > On 16 fev, 12:34, "Norman" <[EMAIL PROTECTED]> wrote: > > > > I have some views for a model with a mix of fields, two of these --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation problem with multiple select boxes
Forget about my previous post, and my sincere apologies to Evan Sagge, his fine piece of code have no connection with my misery. I "baked" from ground up the models, controllers and views for the tables involved and the vanilla CakePHP validation is presenting the same behavior with multiple select listboxes. If any field does not validate, the multiple selects loose their selected options. Norman On 16 fev, 20:06, "Norman" <[EMAIL PROTECTED]> wrote: > One thing I am sure about: This problem is not related with the > "vanilla" CakePHP 1.1 validation. Im using "Evan's CakePHP Validation > Technique 2.0" (http://blog.evansagge.com/2006/12/28/evans-cakephp- > validation-technique-20/) and Im pretty sure theres a bug at the > validation class causing this behavior with multiple select boxes. But > I was not able to find it. > > Norman > > On 16 fev, 12:34, "Norman" <[EMAIL PROTECTED]> wrote: > > > I have some views for a model with a mix of fields, two of these --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation problem with multiple select boxes
One thing I am sure about: This problem is not related with the "vanilla" CakePHP 1.1 validation. Im using "Evan's CakePHP Validation Technique 2.0" (http://blog.evansagge.com/2006/12/28/evans-cakephp- validation-technique-20/) and Im pretty sure theres a bug at the validation class causing this behavior with multiple select boxes. But I was not able to find it. Norman On 16 fev, 12:34, "Norman" <[EMAIL PROTECTED]> wrote: > I have some views for a model with a mix of fields, two of these --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Validation problem with multiple select boxes
I have some views for a model with a mix of fields, two of these fields are select boxes and other two of these fields are multiple select boxes. The multiple ones are rendered with the selectTag html helper method ($html->selectTag('Area/Area', $areas, $selectedAreas, array('multiple' => 'multiple', 'class' => 'selectMultiple'), array(), true)). All of them are not validated at all, you can select or not the single selection ones, and you can select zero or any number of options in the multiple ones. The problem: IF some of the other fields have any validation (an email field, for instance) and IF this field fails validation, when the add or the edit view is re-rendered with the error messages, all selections made at the multiple select boxes are lost, they come back with no elements selected. The single selection boxes keep their previously select values, but the multiple ones does not. And some warnings shows up (4 times): Notice: Undefined index: id in ./cake/libs/controller/ controller.php on line 976 Any help on this will be greatly appreciated! Thanks in advance, Norman --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: form validation problem
Well, i have solved :-) I have to use: var $uses = array('Contact'); instead of var $uses =null; --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
form validation problem
hello, Here is a real newbie question :-) i have created a model to do some validation on a simple form without a db attached. VALID_EMAIL, 'name'=>VALID_NOT_EMPTY, 'content'=>VALID_NOT_EMPTY ); var $useTable = false; //no db! } ?> i read that i have to use "validates" instead of "save" to perform validation if i dont have a db attached. in my controller i need to do something like render("index","mylayout"); } function send() { if ($this->Contact->validates($this->data)) { //do something, sanitize, etc. $this->render("index","mylayout"); } else { // validate errors $this->set('userMessage',"Error!"); $this->render("index","myerrorlayout"); } } } ?> but i get this error: Notice: Undefined property: ContactsController::$Contact Fatal error: Call to a member function validates() on a non-object I am missing something? There is somewere a snippet with a really simple form validation (w/o database?) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation problem
milicic.marko wrote: > I need to validte my model in that way to forbide inserting two posts > with same Title. > OK. This is not an REGEX type of validation so I suppose I must use > some callback function. > I used beforeSave() CB function and returned false if I detect that > post with that title already exists. > But, what I'm supposed to do in order to force cake to behave like it > was an regex type validation failure... > > I want to use $html->tagErrorMsg to present error message I much prefer enforcing this sort of model-integrity issue in the database by using a UNIQUE index on the column in question. This approach only works if what you're saying is true in all cases, of course. Cheers, Matt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Validation problem
Yeah it helped. Tnx dude --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Validation problem
In beforeSave(), before returning false, you can do$this->invalidate($field_name);To me, beforeValidate() seems a little more logical place to put that, though.Hope it works for you.Sohei --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Validation problem
Hi folks, I need to validte my model in that way to forbide inserting two posts with same Title. OK. This is not an REGEX type of validation so I suppose I must use some callback function. I used beforeSave() CB function and returned false if I detect that post with that title already exists. But, what I'm supposed to do in order to force cake to behave like it was an regex type validation failure... I want to use $html->tagErrorMsg to present error message tnx for reading I hope someone will help :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---