My EncomendaLinhas relations:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'encomenda' => array(self::BELONGS_TO, 'Encomenda', 'encomenda'),
'ritmo' => array(self::BELONGS_TO, 'Ritmo', 'style'),
);
}
My code and $encomendaLinha->ritmo is null,i dont know why
action finalizar
if (isset($_GET['encomenda'])) {
$encomenda = Encomenda::model()->findByPk($_GET['encomenda']);
$encomenda->confirmed = true;
$encomenda->save();
foreach ($encomenda->encomendaLinhas as $encomendaLinha) :
$lista= $lista.$encomendaLinha->ritmo;
endforeach;