Try in 3 adding a dot (.)
Bad
echo $form->input('Author name');
Good
echo $form->input('Author.name');
On 10 feb, 17:17, khurram <[email protected]> wrote:
> i have table 'authors' with two columns.The 1st one column is 'id'
> auto incremented.the 2nd one is 'name'.
>
> 1.this is the model
> <?php
> class Author extends AppModel {
> var $name = 'Author';
> }
> ?>
>
> 2.this is the controller
>
> <?php
>
> class AuthorsController extends AppController {
> var $name = 'Authors';
> var $helpers = array('Html','Form');
>
> function index() {
> $this->set('auth', $this->Author->find('all'));
> }
>
> function add() {
> if (!empty($this->data)) {
>
> $this->Author->create();
>
> if ($this->Author->save($this->data)) {
> $this->Session->setFlash('The author has been saved');
> $this->redirect(array('action'=>'index'), null, true);
> } else {
> $this->Session->setFlash('Author not saved. Try again.');
> }
>
> }
> }
>
> }
>
> ?>
>
> 3.and this is the add.ctp
>
> <?php echo $form->create('Author');?>
> <fieldset>
> <legend>Add New Author</legend>
> <?php
> echo $form->input('Author name');
> ?>
> </fieldset>
> <?php echo $form->end('Add');?>
>
> now my problem is that when i click on Add button then it show the
> message "The author has been saved".but actually it does not save and
> not even in the database table,no record is inserted.
> kindly help me i am working on the final project of master of computer
> science.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---