Re: Form data not available in controller
Well, I tried all your suggestions over the weekend, and none of them panned out. count($_POST) tells me the post array is empty, and likewise there is nothing in $this-params['form'] or $this-data. So thanks for the help, but I now suspect the problem lies in my Apache rewrite rules. The site is in a shared hosting environment, and the DocumentRoot directive is not enabled, so I had to write a more complex rewrite rule to get my URL's in proper shape. I'm no Apache expert, so it was a cut and paste job, and I've read that there are situations in which POST data can be inadvertently dumped during rewrites. Anyway, thanks for the assistance, but this deserves a new thread, so I'll repost if I'm still getting nowhere. Thanks, Adam --~--~-~--~~~---~--~~ 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 not available in controller
Sorry, I just meant the error message I added in my controller (the flash message in the else clause) i.e. cakephp doesn't think there's anything in $this-data. In your controller, did you try this : $this-Model-create(); $this-Model-save($this-data); instead of : $this-Model-create($this-data); $this-Model-save(); Since you say that data are POSTed, $this-data is filled. Seems that something is wrong in the save part of your code. --~--~-~--~~~---~--~~ 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 not available in controller
- Please debug the $this-params['form'] and $this-data in your controller's action and take a look at it if something is not working properly On Thu, Apr 24, 2008 at 9:49 PM, zendrumz [EMAIL PROTECTED] wrote: Hey everyone, I'm a cakephp newbie putting together my first project. I'm trying to save form data to my database through a form generated by the formHelper in a view element. The problem I'm having is that $this- data is apparently empty when I try to access it from my controller. I've checked my HTTP headers, and my form data is indeed being POSTed. I've followed all of cakephp's naming conventions and the framework does have proper access to the database. When I submit the form, the controller branches to display the error message in my view, along with the following: 1 query took 2 ms Nr Query Error AffectedNum. rows Took (ms) 1 DESCRIBE `contacts` 6 6 2 Here's the relevant code: Model: class Contact extends AppModel { var $name = 'Contact'; } Controller: class ContactsController extends AppController{ var $name = 'Contacts'; var $helpers = array('Html','Javascript','Form'); function add(){ if (!empty($this-data)){ if($this-Contact-create($this-data) $this-Contact-save()) { $this-flash('Your information has been saved.','/'); } } else{ $this-flash('An error has ocurred. Please contact us directly at: info (at) shrineaudio (dot) com.','/'); } } } Form: div id=contactsdiv h2contact us/h2 ?php echo $form-create('Contact'); echo $form-input('name', array('label' = 'span*Name:/span')); echo $form-input('email', array('label' = 'span*Email:/span')); echo $form-input('phone', array('label' = 'spanPhone:/span')); echo $form-input('message', array('type' = 'textinput','label' = 'span class=leftalign*Tell us about your project:/ span','div'='leftalign')); echo $form-submit('submitbutton.gif'); echo $form-end(); ? /div Any help would be greatly appreciated. As you can see, I essentially copied the code for my model and controller from the blog tutorial, so I'm at a loss as to explain why it isn't working. Thanks a lot! -- Regards, Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org/ http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ 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 not available in controller
When I submit the form, the controller branches to display the error message in my view, along with the following: 1 query took 2 ms NrQuery Error AffectedNum. rows Took (ms) 1 DESCRIBE `contacts` 6 6 2 Well, *which* error message ? It could be helpful :) --~--~-~--~~~---~--~~ 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 not available in controller
On Apr 24, 12:36 pm, seb [EMAIL PROTECTED] wrote: When I submit the form, the controller branches to display the error message in my view, along with the following: 1 query took 2 ms Nr Query Error AffectedNum. rows Took (ms) 1 DESCRIBE `contacts` 6 6 2 Well, *which* error message ? It could be helpful :) Sorry, I just meant the error message I added in my controller (the flash message in the else clause) i.e. cakephp doesn't think there's anything in $this-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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---