I am very new to CakePHP and I'm pretty sure there is a simple answer
to this problem but i have failed to find it.
I am creating a todo list application in which the user can enter the
name of the item for the list and then select the importance of the
item. So I have two models: Item and Importance. In my importance
table I have three levels of importance: A, B, C. In my
items_controller.php file in my view function I am trying to select the
Letter A, B, or C based on the foreignKey importances_id in my items
table and display that letter instead of the importances_id as it does
by default with scaffolding. I have tried various things but here is
the latest attempt.
function view($id)
{
$this->Item->id = $id;
$this->set('data', $this->Item->read());
$im =
$this->Item->finByImportances_id($this->data['Item']['importances_id']);
$this->set('importances',
$this->Importance->findByImportance($im['Item']['importances_id']));
}
Here is the view.thtml file:
<h1>view <?php echo $data['Item']['item']?></h1>
<dl>
<dt>Importance id:</dt>
<dd><?php echo $data['Item']['importances_id']?>
| <?php echo $importances['Importance']['importance']?> </dd>
<dt>Item:</dt>
<dd><?php echo $data['Item']['item']?></dd>
<dt>Created:</dt>
<dd><?php echo $data['Item']['created']?></dd>
<dt>modified:</dt>
<dd><?php echo $data['Item']['modified']?></dd>
<dt>order:</dt>
<dd><?php echo $data['Item']['order_2']?></dd>
</dl>
I am not getting any errors but I am also not returning any value from
<?php echo $importances['Importance']['importance']?>
What am I doing wrong?
My configuration is
cake: 1.1.6.3264
php 5.1.1
apache: 2.0.55
mysql: 5.0.17
I am running it using the Uniform Server.
thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---