Re: validation / FormHelper::error
yes i know, i tested that but the the error message still doesnt appear. i really get headaches right now... --~--~-~--~~~---~--~~ 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 / FormHelper::error
Without using $form->error, cake will default to displaying the error unless you set 'error' => 'false' so you do not have to use $form- >error. You can then define the error message in your model: var $validate = array( 'firstname' => array( 'rule' => 'alphaNumeric', 'required' => true, 'allowEmpty' => false, 'message' => 'First name is required and only alphanumeric characters are allowed' ), 'lastname' => array( 'rule' => 'alphaNumeric', 'required' => true ) ); Alternatively, you can set 'error' => 'false' and return from your controller an array of all errors, if any, using $this->Profile- >invalidFields(); On May 20, 10:58 am, Break <[EMAIL PROTECTED]> wrote: > Hey guys, i got a problem with the formhelper::error. > I'm know tryin for 2 days to fix this problem: > The validation in the code below works fine. if the field is empty the > setFlash-Msg appears and the data isn't saved. > But the error message doesnt appear. > > MODEL > # > > class Profile extends AppModel { > var $name = 'Profile'; > var $belongsTo = array( >'User' => array ( > 'foreignKey' => 'id' >) > ); > var $validate = array( > > 'firstname' => array( > 'rule' => 'alphaNumeric', > 'required' => true > ), > > 'lastname' => array( > 'rule' => 'alphaNumeric', > 'required' => true > ) > > ); > } > > CONTROLLER > > > class ProfilesController extends AppController { > var $name = 'Profiles'; > > function index() { > if(!empty($this->data)) { > $this->Profile->id = $this->Session->read('id'); > if($this->Profile->save($this->data)) { > $this->Session->setFlash('Saved'); > } else { > $this->Session->setFlash('Error'); > } > } > > $this->Profile->id = $this->Session->read('id'); > $profile = $this->Profile->read(); > $this->set('profile', $profile); > } > > } > > VIEW > ## > > create('Profile', array('action' => 'index'));?> > input('firstname', array('value' => $profile['Profile'] > ['firstname'], 'size' => 50, 'maxlength' => 100, 'label' => > 'Firstname', 'class' => 'input', 'div' => false));?> > error('firstname', 'Please fill in firstname');?> > end();?> > > I hope you can help me. > (sorry for mistakes my english is not the best) --~--~-~--~~~---~--~~ 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 / FormHelper::error
Hey guys, i got a problem with the formhelper::error. I'm know tryin for 2 days to fix this problem: The validation in the code below works fine. if the field is empty the setFlash-Msg appears and the data isn't saved. But the error message doesnt appear. MODEL # class Profile extends AppModel { var $name = 'Profile'; var $belongsTo = array( 'User' => array ( 'foreignKey' => 'id' ) ); var $validate = array( 'firstname' => array( 'rule' => 'alphaNumeric', 'required' => true ), 'lastname' => array( 'rule' => 'alphaNumeric', 'required' => true ) ); } CONTROLLER class ProfilesController extends AppController { var $name = 'Profiles'; function index() { if(!empty($this->data)) { $this->Profile->id = $this->Session->read('id'); if($this->Profile->save($this->data)) { $this->Session->setFlash('Saved'); } else { $this->Session->setFlash('Error'); } } $this->Profile->id = $this->Session->read('id'); $profile = $this->Profile->read(); $this->set('profile', $profile); } } VIEW ## create('Profile', array('action' => 'index'));?> input('firstname', array('value' => $profile['Profile'] ['firstname'], 'size' => 50, 'maxlength' => 100, 'label' => 'Firstname', 'class' => 'input', 'div' => false));?> error('firstname', 'Please fill in firstname');?> end();?> I hope you can help me. (sorry for mistakes my english is not the best) --~--~-~--~~~---~--~~ 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: Formhelper error
Wow! It really worked! Thanks! I have been suspecting that the Model Class was at fault, but couldn't pin point the error. Thanks a lot! On Jan 26, 8:14 am, arambi <[EMAIL PROTECTED]> wrote: > Hello > > I had the same problem and I have solved it. The problem was that I > had the property $validate of the model defined but without pointing > out that it is an array. The solution is the following one. You must > write in the model > > var $validate = array () > > And it should work well > > Greetings > > On 8 ene, 12:11, ProFire <[EMAIL PROTECTED]> wrote: > > > > > Just an update the the problem I'm encountering: > > > I have quite a number tables in my database. The only time I'm > > encountering thiserror(So far) is when I use theformhelperon this > > specific table called "accounts". I have other tables like "tasks" and > > I have usedformhelperwith it. No sucherrorcame out. > > > I'm beginning to think that theerrorcould be resulted from a faulty > > Model Construction. Or maybe it's a bug with the core? Or maybe it's > > my tableerror? > > > I'm not sure. Anybody have a solution to this problem? > > So far it hasn't caused me any serious problem and my application > > still works fine. But the warning message keeps popping up and as a > > developer, I don't quite like my application to have even a warning. > > It's a precaution to prevent future pitfalls.- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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: Formhelper error
Hello I had the same problem and I have solved it. The problem was that I had the property $validate of the model defined but without pointing out that it is an array. The solution is the following one. You must write in the model var $validate = array () And it should work well Greetings On 8 ene, 12:11, ProFire <[EMAIL PROTECTED]> wrote: > Just an update the the problem I'm encountering: > > I have quite a number tables in my database. The only time I'm > encountering thiserror(So far) is when I use theformhelperon this > specific table called "accounts". I have other tables like "tasks" and > I have usedformhelperwith it. No sucherrorcame out. > > I'm beginning to think that theerrorcould be resulted from a faulty > Model Construction. Or maybe it's a bug with the core? Or maybe it's > my tableerror? > > I'm not sure. Anybody have a solution to this problem? > So far it hasn't caused me any serious problem and my application > still works fine. But the warning message keeps popping up and as a > developer, I don't quite like my application to have even a warning. > It's a precaution to prevent future pitfalls. --~--~-~--~~~---~--~~ 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: Formhelper error
True! I also figured it's not needed. I added it in as part of the process of debugging. The problem is, whether I specify it or not, the warning message still appears. So the second argument isn't the cause of it. Hmmm... Is there any other possible errors that I have made that caused this warning message to appear? Can I provide more data for you guys to analyse better? I'm using CakePHP v1.2.0.6311 beta, PHP5, MySQL 5.0, Window XP Pro, Apache 2.0 I have tried many ways, such as specifying the $options["type"] (thus the empty array). I still haven't figure out the cause of it. Anybody encountering similar problem? On Jan 8, 9:47 pm, "Chris Hartjes" <[EMAIL PROTECTED]> wrote: > On Jan 6, 2008 10:10 PM, ProFire <[EMAIL PROTECTED]> wrote: > > > > > In my view, this is how I use my form: > > echo $form->input("Account.username", array()); > > Why are you passing an empty array as the second parameter? It's not needed. > > -- > Chris Hartjes > Internet Loudmouth > Motto for 2008: "Moving from herding elephants to handling snakes..." > @TheKeyBoard:http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ 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: Formhelper error
On Jan 6, 2008 10:10 PM, ProFire <[EMAIL PROTECTED]> wrote: > > > In my view, this is how I use my form: > echo $form->input("Account.username", array()); > Why are you passing an empty array as the second parameter? It's not needed. -- Chris Hartjes Internet Loudmouth Motto for 2008: "Moving from herding elephants to handling snakes..." @TheKeyBoard: http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ 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: Formhelper error
Just an update the the problem I'm encountering: I have quite a number tables in my database. The only time I'm encountering this error (So far) is when I use the formhelper on this specific table called "accounts". I have other tables like "tasks" and I have used formhelper with it. No such error came out. I'm beginning to think that the error could be resulted from a faulty Model Construction. Or maybe it's a bug with the core? Or maybe it's my table error? I'm not sure. Anybody have a solution to this problem? So far it hasn't caused me any serious problem and my application still works fine. But the warning message keeps popping up and as a developer, I don't quite like my application to have even a warning. It's a precaution to prevent future pitfalls. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Formhelper error
Hi, I'm often getting this error whenever I use the FormHelper. I'm using CakePHP v1.2.0.6311 beta. Warning (2): array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object [CORE\cake\libs \view\helper.php, line 344] In my view, this is how I use my form: echo $form->input("Account.username", array()); So far as I used the application, it's not causing me any obvious problems. But I would like to know what's causing this warning and is there a way to remove it? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---