I was looking for the previous answer, but the ones I found are related to older versions of cakephp
I have two tables: “logs” and “problems”, where there is a relationship of “problems” of BelongsTo “logs”, here is what the problem looks like:
public function initialize(array $config){ $this->belongsTo('Magazines', [ 'foreignKey' => 'id' ]); }
Magazines Magazines
have two fields: journ.id and journ.name
problems with tables have two fields: issues.id, issues.magazine_id, where issues.magazine_id is the foreign key
to fill the selected input in the problem view with .name log values and save the .magazine_id problems, I installed the controller as follows
$this->set('magazines', $this->Issue->Magazine->find('list'));
then I added the following code to the add.cpt problem view
<?php echo $this->Form->input('name', [ 'type' => 'select', 'multiple' => false, 'options' => $magazines, 'empty' => true]); ?>
but I get select input with .magazine_id questions as values instead of logs. name
thanks for your help and comments
Raul Magdalena Catala
source share