When you "View" your data (see view baked action) the data from your
model is setted in a variable. For example, in PostsController, the
view action is similar to:

   $post = $this->Post->read(null,$id)
   $this->set('post',$post)

In the edit action, that data read from the DB is asigned to $this-
>data. Something like:
   $this->data = $this->Post->read(null,$id)

$this->data is a special array that views and controller can use.
Becouse when you want to save your data to your database you do $this-
>Post->save($this->data). So, you should combine it. For example, set
the data in $this->data, and in your view, you can do something like
this:

view_edit.ctp
   <span><?php echo $this->data['Post']['title']</span> <a href='#'
id='doMyMagicThing'>Edit this field</a>

    // then, with some javascript (i use JQuery) magic you can do
something like this:
   $("doMyMagicThing").click(function(e){
      //here i'll transform the <span> tag in a <input> tag and allow
the guy to edit this
   });

Hope it helps!

Best regards.

On Aug 14, 11:23 pm, "Ma'moon" <[email protected]> wrote:
> Put the same content that you got from the database in a form contained
> within a hidden <div>, offer a link or a button named "Edit", onclick at
> that button show the hidden <div> that contains the form which will save
> "edit" the data.
>
> Am not really sure if that would be a CakePHP related issue though!
>
>
>
>
>
>
>
> On Sun, Aug 14, 2011 at 9:45 PM, nOLL <[email protected]> wrote:
> > Hi,
>
> > i would like to create page that can view the data from the database.
> > At the same time, i could directly edit the data rather than create
> > another link to update the data.
>
> > How can i do this?
>
> > Thanks.
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > [email protected] For more options, visit this group
> > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to