Re: Help With Validation Question
I forgot to mention, you need to set $this->Model->id before you call saveField On Tue, Dec 8, 2009 at 6:06 PM, Dave wrote: > Sounds like you are creating a new entry instead of saving the data from > the current one. > > Try using $this->Model->saveField('field_name','value'); > > So in your controller check which field they have field out, and call > saveField for only that field. > > > On Tue, Dec 8, 2009 at 1:30 PM, Dave wrote: > >> I am attempting to allow user to edit their url and email, so i load the >> form up and leave it blank since both have to be unique if its filled with >> their original info and edit 1 field the other will fail because it says >> email / or url already exists since they only changed one. So save the form >> and the field they did not edit is now empty in the db. If i try the >> if(empty($this->data['User']['email']) >> { >> $this->data['User']['email']) = $user['User']['email']; >> >> ] >> >> it fails because it says its already used >> >> I tried thinking how to do this and every way i try fails. The form has 2 >> fields, url and email. Validation is set so they are not required, allow >> empty since they may only be changing 1 or the other but unique so whatever >> they change it to can not be in the db already and valid url or email for >> the field. >> >> Any ideas? >> >> Thanks >> >> Dave >> >> 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
Re: Help With Validation Question
Sounds like you are creating a new entry instead of saving the data from the current one. Try using $this->Model->saveField('field_name','value'); So in your controller check which field they have field out, and call saveField for only that field. On Tue, Dec 8, 2009 at 1:30 PM, Dave wrote: > I am attempting to allow user to edit their url and email, so i load the > form up and leave it blank since both have to be unique if its filled with > their original info and edit 1 field the other will fail because it says > email / or url already exists since they only changed one. So save the form > and the field they did not edit is now empty in the db. If i try the > if(empty($this->data['User']['email']) > { > $this->data['User']['email']) = $user['User']['email']; > > ] > > it fails because it says its already used > > I tried thinking how to do this and every way i try fails. The form has 2 > fields, url and email. Validation is set so they are not required, allow > empty since they may only be changing 1 or the other but unique so whatever > they change it to can not be in the db already and valid url or email for > the field. > > Any ideas? > > Thanks > > Dave > > 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
Help With Validation Question
I am attempting to allow user to edit their url and email, so i load the form up and leave it blank since both have to be unique if its filled with their original info and edit 1 field the other will fail because it says email / or url already exists since they only changed one. So save the form and the field they did not edit is now empty in the db. If i try the if(empty($this->data['User']['email']) { $this->data['User']['email']) = $user['User']['email']; ] it fails because it says its already used I tried thinking how to do this and every way i try fails. The form has 2 fields, url and email. Validation is set so they are not required, allow empty since they may only be changing 1 or the other but unique so whatever they change it to can not be in the db already and valid url or email for the field. Any ideas? Thanks Dave 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: Help with validation
Ok, I never saw that post :D Continue the good work :) On Oct 20, 9:13 am, "Dave Maharaj :: WidePixels.com" wrote: > I posted the code for the view, model, controller in a reply to my original. > But I did get it all figured out. > > Thanks, > > Dave > > -Original Message- > From: John Andersen [mailto:j.andersen...@gmail.com] > Sent: October-20-09 3:03 AM > To: CakePHP > Subject: Re: Help with validation > > Please show the code that delivers the input data to the model, so that we > may be convinced that the data you receive from the form is also the data > sent to the model for validation :) Also possibly the view code for the > form. > Enjoy, > John > > On Oct 19, 5:15 pm, "Dave Maharaj :: WidePixels.com" > wrote: > > I mean when I hit submit the form gets sent and comes back invalid but > > nothing is marked as invalid (even when I leave it completely empty). > > Then same page without refreshing or anything just hit submit on that > > same returned form it comes back with errors. Even if I have letters / > > numbers in the field it says Can not be empty. > > > Just weird. > > > Dave > > > -----Original Message- > > From: WebbedIT [mailto:p...@webbedit.co.uk] > > Sent: October-19-09 5:08 AM > > To: CakePHP > > Subject: Re: Help with validation > > > Firstly, you are trying very simple validation so there must be > > something very simple wrong with it that's easily fixed when > > identified. Have you got validation working anywhere else in your app? > > > When you say hit submit and nothing do you mean it shows the form > > again and is this because it has failed to validate? > > > You maybe want to echo $this->validationErrors in your view to see > > what errors you are getting, it may be that you are getting the errors > > but something is up with the form field naming that is stopping the > > automagic working. > > > In my controllers I personally go for the following approach rather > > than validating first as save does that for you. > > > if($this->Model->save($this->data)) { > > // Validated and saved, save a flash message and redirect to desired > > page } else { > > // Failed, show form again with errors } --~--~-~--~~~---~--~~ 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: Help with validation
I posted the code for the view, model, controller in a reply to my original. But I did get it all figured out. Thanks, Dave -Original Message- From: John Andersen [mailto:j.andersen...@gmail.com] Sent: October-20-09 3:03 AM To: CakePHP Subject: Re: Help with validation Please show the code that delivers the input data to the model, so that we may be convinced that the data you receive from the form is also the data sent to the model for validation :) Also possibly the view code for the form. Enjoy, John On Oct 19, 5:15 pm, "Dave Maharaj :: WidePixels.com" wrote: > I mean when I hit submit the form gets sent and comes back invalid but > nothing is marked as invalid (even when I leave it completely empty). > Then same page without refreshing or anything just hit submit on that > same returned form it comes back with errors. Even if I have letters / > numbers in the field it says Can not be empty. > > Just weird. > > Dave > > -Original Message- > From: WebbedIT [mailto:p...@webbedit.co.uk] > Sent: October-19-09 5:08 AM > To: CakePHP > Subject: Re: Help with validation > > Firstly, you are trying very simple validation so there must be > something very simple wrong with it that's easily fixed when > identified. Have you got validation working anywhere else in your app? > > When you say hit submit and nothing do you mean it shows the form > again and is this because it has failed to validate? > > You maybe want to echo $this->validationErrors in your view to see > what errors you are getting, it may be that you are getting the errors > but something is up with the form field naming that is stopping the > automagic working. > > In my controllers I personally go for the following approach rather > than validating first as save does that for you. > > if($this->Model->save($this->data)) { > // Validated and saved, save a flash message and redirect to desired > page } else { > // Failed, show form again with errors } --~--~-~--~~~---~--~~ 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: Help with validation
Please show the code that delivers the input data to the model, so that we may be convinced that the data you receive from the form is also the data sent to the model for validation :) Also possibly the view code for the form. Enjoy, John On Oct 19, 5:15 pm, "Dave Maharaj :: WidePixels.com" wrote: > I mean when I hit submit the form gets sent and comes back invalid but > nothing is marked as invalid (even when I leave it completely empty). Then > same page without refreshing or anything just hit submit on that same > returned form it comes back with errors. Even if I have letters / numbers in > the field it says Can not be empty. > > Just weird. > > Dave > > -Original Message- > From: WebbedIT [mailto:p...@webbedit.co.uk] > Sent: October-19-09 5:08 AM > To: CakePHP > Subject: Re: Help with validation > > Firstly, you are trying very simple validation so there must be something > very simple wrong with it that's easily fixed when identified. Have you got > validation working anywhere else in your app? > > When you say hit submit and nothing do you mean it shows the form again and > is this because it has failed to validate? > > You maybe want to echo $this->validationErrors in your view to see what > errors you are getting, it may be that you are getting the errors but > something is up with the form field naming that is stopping the automagic > working. > > In my controllers I personally go for the following approach rather than > validating first as save does that for you. > > if($this->Model->save($this->data)) { > // Validated and saved, save a flash message and redirect to desired page > } else { > // Failed, show form again with errors } --~--~-~--~~~---~--~~ 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: Help with validation
I mean when I hit submit the form gets sent and comes back invalid but nothing is marked as invalid (even when I leave it completely empty). Then same page without refreshing or anything just hit submit on that same returned form it comes back with errors. Even if I have letters / numbers in the field it says Can not be empty. Just weird. Dave -Original Message- From: WebbedIT [mailto:p...@webbedit.co.uk] Sent: October-19-09 5:08 AM To: CakePHP Subject: Re: Help with validation Firstly, you are trying very simple validation so there must be something very simple wrong with it that's easily fixed when identified. Have you got validation working anywhere else in your app? When you say hit submit and nothing do you mean it shows the form again and is this because it has failed to validate? You maybe want to echo $this->validationErrors in your view to see what errors you are getting, it may be that you are getting the errors but something is up with the form field naming that is stopping the automagic working. In my controllers I personally go for the following approach rather than validating first as save does that for you. if($this->Model->save($this->data)) { // Validated and saved, save a flash message and redirect to desired page } else { // Failed, show form again with errors } --~--~-~--~~~---~--~~ 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: Help with validation
Firstly, you are trying very simple validation so there must be something very simple wrong with it that's easily fixed when identified. Have you got validation working anywhere else in your app? When you say hit submit and nothing do you mean it shows the form again and is this because it has failed to validate? You maybe want to echo $this->validationErrors in your view to see what errors you are getting, it may be that you are getting the errors but something is up with the form field naming that is stopping the automagic working. In my controllers I personally go for the following approach rather than validating first as save does that for you. if($this->Model->save($this->data)) { // Validated and saved, save a flash message and redirect to desired page } else { // Failed, show form again with errors } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Help with validation
No matter what I try I cant get validation to work properly. (i am only trying to get it working so please no comments about numbers in a firstname :) simple validation on 1 field: 'firstname' => array( 'firstnameRule-1' => array( 'rule' => 'alphaNumeric', 'message' => 'Only alphabets and numbers allowed', 'required' => true, 'last' => true), 'firstnameRule-2' => array( 'rule' => array('minLength', 8), 'message' => 'Minimum length of 8 characters', 'last' => true), 'firstnameRule-3' => array( 'rule' => 'notEmpty', 'message' => 'Please enter your first name.', 'last' => true), ), When the page renders Firstname: is bold as its required. Hit submit and nothing...hit submit again(without refreshing the page) and then "Only alphabets and numbers allowed". I tried if $this-user->validates(); save($this->data, true $fields) but nothing seems to be going as planned. What am i doing wrong here? Thanks, Dave --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Help with validation rule in behaviour
Hi guys, I am completely stuck and cannot figure out what I am doing wrong. I have created a custom Upload behaviour but I cannot get the following validation rule to work. Just after the setup function in the behaviour I call this function _create_validation_rule(&$model){} which sets the validation rules, for my suprise nothing happens. When I call the function from inside the beforeValidate function it works, but Cake display the following error: Warning (2): preg_match() expects parameter 2 to be string, array given [CORE\cake\libs\validation.php, line 877] When I checked the validation.php and pr ( ) the second paramenter it showed the file array: Array ( [filename] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) ) I must be doing something wrong somewhere, just don't know where and how to fix it. Any help would very much appreciated. Many thanks in advance. Cheerss --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---