Hey everybody
I'd like to know how to display a list of
Manufacturers (associated with Cars) in a combobox when I create cars.
My Mysql query returns it:
SELECT `Carro`.`id`, `Carro`.`fabricante_id`, `Carro`.`nome`,
`Carro`.`modelo`, `Carro`.`blindado`, `Carro`.`cor`, `Carro`.`ano`,
`Carro`.`preco`, `Fabricante`.`id`, `Fabricante`.`nome` FROM `carros`
AS `Carro` LEFT JOIN `fabricantes` AS `Fabricante` ON
(`Carro`.`fabricante_id` = `Fabricante`.`id`) WHERE 1 = 1
// Where fabricante = Manufacturer and Carro = Car.
My models are:
models/carro.php:
class Carro extends AppModel
{
var $name = "Carro";
var $belongsTo = 'Fabricante';
}
models/fabricante.php:
class Fabricante extends AppModel
{
var $name = "Fabricante";
var $hasMany = array('Carro' => array(
'className' => 'Carro',
'foreignKey' => 'fabricante_id',
'dependent'=> true
)
);
}
Does anyone have any idea how to display the Manufacturers into a
combobox at Cars 'add' view?
I only know how to do it in Ruby on Rails and it seems kind of
different to implement.
Best wishes,
Uriel
--
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