Hi Vikas,

I am relatively new to CakePHP too.  I learned lots by using "cake
bake" to create default Models, Views & Controllers, then reverse
engineering them to see how it's done.  I would recommend this
approach, in conjunction with lots of consultation to the Manual.


Cheers Paul.



On Dec 18, 9:09 am, vikas <[email protected]> wrote:
> hello everyone,
>
>  as I m new for cake php i m leaning myself cakephp...
>
> I want help about fill the form when we edit any record from databse.
>
> for example I have a edit() method in posts_controller as per below..:
> ------------------------------------------------------------------------------------
> function edit($id = null) {
>    if (!$id && empty($this->data)) {
>     $this->Session->setFlash(__('Invalid Post', true));
>     $this->redirect(array('action'=>'index'));
>    }
>    if (!empty($this->data)) {
>     if ($this->Post->save($this->data)) {
>      $this->Session->setFlash(__('The Post has been saved', true));
>      $this->redirect(array('action'=>'index'));
>     }
>     else {
>      $this->Session->setFlash(__('The Post could not be saved. å
>      Please try again.', true));
>     }
>    }
>    if (empty($this->data)) {
>
>       $this->data = $this->Post->read(null, $id);
>    }
>    $tags = $this->Post->Tag->find('list');
>    $users = $this->Post->User->find('list');
>    $this->set(compact('tags','users'));
>   }
>
> -------------------------------------------------------------------------------------
>
> In edit.ctp i have written code as per below:
> ----------------------------------------------------------
> <h1>Edit Post</h1>
> <?php
> echo $form->create('Post', array('action' => 'edit'));
> echo $form->input('Name');
> echo $form->input('Content', array('rows' => '3'));
> echo $form->input('id', array('type'=>'hidden'));
> echo $form->end('Save Post');
> ?>
> -------------------------------------------------------
>
> Now when i edit data the form field becomes blank as like filling new
> form.. so what i will do to fill form??
>
> Please help me out...
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to