-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Raji,


the main difference between edit and add is the existence of the id field.
Check via debug in your view if the infomation is tehre and via debug in
the controller just short before saving if your id is set in the
$this->request->data array.

That should point you to the source of your problem.


Calamity JAbe



Am 13.06.2014 13:01, schrieb raji gudivada:
> Hello
>      I  am new to cakephp framework. In database I have grades table. I 
> prepared Two pages using cakephp i.e..Add grade and Manage Grade. Now i am 
> trying to add actions in managegrade ie.. Edit and Delete. Delete function 
> is working but Edit function is not working.It is treated as new record 
> instead of editing, it was saving as a new record.I used the following code.
> In GradeController
>  public function edit($id = null) {
>                     if (!$id && empty($this->data)) {
>                         $this->Session->setFlash('Invalid grade');
>                         $this->redirect(array('action' => 'managegrade'));
>                     }
>                     if (!empty($this->data)) {
>                         if ($this->grade->save($this->data)) {
>                             $this->Session->setFlash('The grade has been 
> saved');
>                             $this->redirect(array('action' => 
> 'managegrade'));
>                         } else {
>                             $this->Session->setFlash('The grade could not 
> be saved. Please, try again.');
>                         }
>                     }
>                     if (empty($this->data)) {
>                         $this->data = $this->grade->read(null, $id);
>                     }
>                 }
>  In edit.ctp i used the following code
> <h1>Edit Grade </h1>
> <?php
> echo $this->Form->create('Movie');
> echo $this->Form->input('id');
> 
> ?>
> Organisation <font color=red>*</font> </br>
> <select>
>   <option value="organisation_id">Common Core</option>
>   </select></br></br>
>   Grade Name <font color=red>* </font> <input type="text" name="name"> </br>
>   Description <textarea rows="4" cols="50" name="description">
>     </textarea>
> <p><b>Status</b></p>
> <input type="radio" name="status" value="Draft" /> Draft<br /> </br>
> <input type="radio" name="status" value="Published" />Published<br /></br>
> <input type="radio" name="status" value="Inactive" />Inactive<br /></br>
> <?php
> echo $this->Form->end('edit');
> 
> ?>
> </div>
> I added the following  link in managegrade
> <?php echo $this->Html->link('Edit',
> array('action' => 'Edit', $grade['grade']['id'])); ?>
>                       
> Please find the error and help me how to edit the existing data
>    Thanks in advance.
> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlOcnTwACgkQbOdiIJzHNKFy4ACeO+IYzfgl5gHLkzTYR6Df6nLW
0SsAn3E8BpTgL1ippstzkihocs9OkkUu
=hn+1
-----END PGP SIGNATURE-----

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to