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 Affected Num. 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">
<h2>contact 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' => '<span>Phone:</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!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---