On 10/12/2010 4:43 AM, Jonathan Sibley wrote:
Hi all,
After a long search, I posted here for help, and after even more
search I found the solution I was looking for. In the PhotoController
add() I am passing the data from the recently saved Photo row to the
view with:
function add() {
if (!empty($this->data)) {
$this->Photo->create();
$this->Photo->set('user_id',
$this->AuthExt->user('id'));
if ($this->Photo->save($this->data)) {
$this->Session->setFlash(__('The photo has been
saved', true));
// Pass the data that was just added to the
database back to the
"add" view so that a thumbnail can be displayed.
$id = $this->Photo->getLastInsertId();
$this->set('photoObjJustSaved',$this->Photo->findById($id));
} else {
$this->Session->setFlash(__('The photo could
not be saved. Please,
try again.', true));
}
}
}
So I guess my question now is, is using:
$id = $this->Photo->getLastInsertId();
$this->set('photoObjJustSaved',$this->Photo->findById($id));
the best way to do it? It seems like another database query when one
might not be required.
Thanks,
Jonathan
On Oct 11, 8:54 pm, Jonathan Sibley<jonsib...@gmail.com> wrote:
Hello,
I have a form to add a Photo in my "add" view (add.ctp). I have two
fields in the view:
echo $form->hidden('Photo.user_id',array('value'=>$user['User']
['id']));
echo $form->input('file', array('type' => 'file'));
Although there are only two fields here, I am using a Helper that
takes the uploaded image and saves file_name, file_type, file_size and
some other columns to the database.
I would like to be able to use this data immediately after the user
submits the form to render the image the image for the user (i.e. in
add.ctp again).
When I try $this->data['Photo'] I just get:
array(
"user_id" => "1",
"file" => array()
)
Which is simply the data I submitted. I would like to pass back the
data from my PhotoController via my add() function, but I can't quite
figure out how. Can anyone help?
Thanks in advance,
Jonathan
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
Hello
We can use:
$saved = $this->Photo->save($this->data)
and you will have the saved data into $saved.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en