Accessing Data in a Controller rather than view
Hi, How can I access data within a controller? Lets say I have the following find() method in my controller $mydata=$this->User->find('all', array('conditions'=>'new;), 'fields'=>array('name')) Let's say I wanted to do some sort of proccessing to that data before outputting to a view How would I do that? I see examples of how to output that data in the view but I see none about accessing the data from within the controller. I figure I should do a loop but how should I write $mydata? Should it be like this: $mydata['User']['name'] ? That seems to work in the view but I get a "Undefined Index" error when I write it that way from within the controller. I don't have the issue when a method returns one record such as field () because it is not returning an array I hope I'm not confusing anyone :( --~--~-~--~~~---~--~~ 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: Error message for the extension validation rule will not display
Thanks guys... I didn't see that missing closing parentheses, Unfortunately the error message still did not show but I figured it out. In my view I added the following line: echo $form->error('imagename'); --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Error message for the extension validation rule will not display
Hi, I am new to CakePHP and I am having trouble getting the extension error message to display. The error message for the email rule displays fine when someone enters an improperly formatted email and I tried other examples of Cake's built in validation, they all seem to work fine except for the extension validation. Can someone please tell me what I am doing wrong. Here are the validation rules in my model: var $validate = array( 'imageupload' => array( 'rule' => array('extension', array('gif', 'jpeg', 'png', 'jpg'), 'message' => 'Please supply a valid image.' ) ) , 'email'=>array( 'rule'=>'email', 'message'=>'Please enter a proper email' ) ); Here is the snippet code in the Controller: function add(){ if (!empty($this->data)) { if($this->Student->save($this->data)){ $this->flash('Success','/add'); } } } Finally the snippet code in my view: create('Student',array('type' => 'file')); echo $form->input('email'); echo $form->file('imageupload'); echo $form->end('Add'); ?> Again, the display message for the email displays correctly so I know that the validation is working at least somewhat. The validation for the file upload seems to operate correctly. If I try to upload a file with a .DOC extension the "save" fails except that it does not display the error message at all. Please help what am I doing wrong? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---