i’ve been traying to change the display value of a variable sent by the controller, but can’t figure it out how,
this is in my controller
$tblSucursales = $this->TblOfertas->TblSucursales->find('all')->contain('TblEmpresas');
$this->set('tblSucursales', $tblSucursales);
that is in an ADD function, here is full code:
public function add()
{
$tblOferta = $this->TblOfertas->newEntity();
if ($this->request->is('post')) {
$tblOferta = $this->TblOfertas->patchEntity($tblOferta, $this->request->data);
if ($this->TblOfertas->save($tblOferta)) {
$this->Flash->success(__('The tbl oferta has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The tbl oferta could not be saved. Please, try again.'));
}
}
$tblCategorias = $this->TblOfertas->TblCategorias->find('all');
$tblSucursales = $this->TblOfertas->TblSucursales->find('all')->contain('TblEmpresas');
$this->set('tblSucursales', $tblSucursales);
$this->set('tblCategorias', $tblCategorias);
$this->set('tblOferta', $tblOferta);
$this->set('_serialize', ['tblOferta']);
}
if i debug $tblSucursales it works excellent, all data is there (every tblSucursal hasOne tblEmpresa):
now, in my add.ctp i want to show tblSucursal.nombre concatenated tbl.Sucursal.tblEmpresa.nombre
i’ve tryed many ways but always getting the same result, error. i can’t even get the name attribute of tblSucursales
echo $this->Form->input('tbl_sucursales._ids', ['options' => $tblSucursales.nombre]);
this is my full code of add.ctp
<nav class="large-3 medium-4 columns" id="actions-sidebar">
<ul class="side-nav">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Html->link(__('List Tbl Ofertas'), ['action' => 'index']) ?></li>
</ul>
</nav>
<div class="tblOfertas form large-9 medium-8 columns content">
<?= $this->Form->create($tblOferta) ?>
<fieldset>
<legend><?= __('Añadir Oferta') ?></legend>
<h2></h2>
<?php
echo $this->Form->input('nombre');
echo $this->Form->input('descripcion');
echo $this->Form->input('nombre_imagen');
echo $this->Form->input('fecha_creacion');
echo $this->Form->input('estado_activa');
echo $this->Form->input('fecha_inicio');
echo $this->Form->input('fecha_fin');
echo $this->Form->input('duracion_dias');
echo $this->Form->input('nombre_encargado');
echo $this->Form->input('telefono_encargado');
echo $this->Form->input('email_encargado');
echo $this->Form->input('tbl_categoria_id', ['options' => $tblCategorias]);
echo $this->Form->input('tbl_sucursales._ids', ['options' => $tblSucursales.nombre]);
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
this is how it looks like if a just put raw $tblSucursales
echo $this->Form->input('tbl_sucursales._ids', ['options' => $tblSucursales]);
Please Help ME!