I have cakePhp 2.5, I need to retrieve data from a table and a hasmany relation and I don’t know how to do it, I tried with joins and with contain but doesn´t show the value of the fields, it says ‘Undefined index: User’, this is the code of the controller:
And this is the code of the view:
Eventos
<?php
echo $this->Html->link('Agregar evento',array('controller'=>'Eventos','action'=>'add'),array('class'=>'btn btn-success')); ?>
<?php
foreach ($model as $evento):
?>
<?php endforeach; ?>
<?php unset($evento); ?>
Descripción
Usuario
Paciente
Agenda
Cantidad
Fecha
Observaciones
Acciones
<?php echo $evento['Eventos']['descripcion']; ?>
<?php echo $evento['EventosxUser']['User']['full_name']; ?>
<?php echo $evento['Pacient']['full_name']; ?>
<?php echo $evento['Agendas']['descripcion']; ?>
<?php echo $evento['EventosxUser']['cantidad']; ?>
<?php echo $evento['EventosxUser']['fecha_entrega']; ?>
<?php echo $evento['Eventos']['observacion']; ?>
<?php echo $this->Html->link(' ',array('action' => 'edit', $evento['Eventos']['id']),array('escape' => false,'class' => 'btn btn-primary','title' => 'Editar') // This line will parse rather then output HTML
);
?>
<?php echo $this->Form->postLink(' ',array('action' => 'delete', $evento['Eventos']['id']),array('confirm' => 'Esta seguro?','escape' => false,'class' => 'btn btn-danger','title' => 'Eliminar')
);
?>