vikas
unread,Dec 8, 2008, 12:02:24 PM12/8/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to CakePHP Bleeding Edge
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...