On Tue, Apr 19, 2011 at 4:11 AM, dvvbrook79
<[email protected]> wrote:
> DAM!!...Scrap that last note:
> Just been checking the DB and theres is nothing for the forms, and i
> just thought whilst looking...i dont need to store the "Reciprocal
> Link" i just need it to show up in the email....Now im really
> confused...PLEASE HELP!!
If there's no column for reciprocallink in the DB, when you save the
Link, that information will be ignored. You problem is that you're
saving the submitted data, then fetching it from the DB to create a
view var named $link. You're then trying to access reciprocallink from
the $link var. But, of course, there being no reciprocallink column in
the DB, $link will not contain it.
So you have two options.
1: Create the column in the DB table. The reciprocallink will be
stored and will also appear in $link for your view.
2: Set a separate view var for reciprocallink.
$this->set(
'link',
$this->Link->findById($this->Link->id)
);
$this->set(
'reciprocallink'
$reciprocallink
);
view:
<td><?php echo $reciprocallink; ?></td>
I think 1 is the simplest solution and makes most sense. If you're
going to store Link it may as well include reciprocallink.
However, it's unclear to me why you're doing an extra find immediately
after saving. Unless you have some need for the ID (it doesn't appear
so) or one or more fields are altered in a beforeSave or afterSave
calback in the Link model, there's no need to call find() after
saving. You could just do something like this:
function submit()
{
if (!empty($this->data))
{
// do CAPTCHA validation ...
$this->Link->create();
$this->data['Link']['approved'] = 0;
$this->Link->set($this->data);
if ($this->Link->validates())
{
// validation ok, try to save
if ($this->Link->save($this->data))
{
$this->set(
'link',
$this->data['Link']
);
// send email
}
else
{
// save failed, set flash msg
}
}
else
{
// validation failed, set flash msg
}
}
$this->set(
'categories',
$this->Link->getCategories()
);
}
view:
<td><?php echo $link['title']; ?></td>
...
<td><?php echo $link['description']; ?></td>
...
<td><?php echo $link['reciprocallink']; ?></td>
Notice that you don't need to include ['Link'] in the view because
$link was set from $this->data['Link'], not $this->data.
You should also do $this->Link->set($this->data), then perform
validation, setting flash messages as needed.
--
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