Hi I have 2 table, a Ticket table and a comments table.
In ticketsTable.php
$this->hasMany('Comments', [
'foreignKey' => 'ticket_id'
]);
and in commentsTable.php
$this->belongsTo('Tickets', [
'foreignKey' => 'comment_id',
]);
}
When I read the data, all is fine, e.g in edit function.
I can run with foreach over all comments and show them.
$ticket = $this->Tickets->get($id, contain: [‘Comments’]);
foreach($comments as $entity)
{
echo h($entity->created->nice());
echo $this->Text->autoParagraph(h($entity->comment));
}
But how to add a new Comment in a form and save it?