Does anybody know how to select the contents of one take from a different view in CakePHP?
I have a take itemgroups
that has 2 fields ID
and Description
. I need to make a down down list in the item add page but I can not find a good way to get all of the values from another table into an array to put into the page.
Below I have also listed my models for each.
<?php
class Item extends AppModel
{
var $name = 'Item';
var $belongsTo = 'Itemgroup';
}
?>
class Itemgroup extends AppModel
{
var $name = 'Itemgroup';
var $hasOne = array('Item');
var $validate = array(
'description' => array(
'rule' => 'notEmpty'
),
'description' => array(
'rule' => 'notEmpty'
)
);
}
?>
You can use like this in your controller and view...
If you want to show initially select value in dropdown then you can pass value where use null in above line.
This is the right solution in my opinion: of choices
from column SET
orENUM
typeplease use
In View :