Add logic of another controller

Hi everyone,

I think i have a lack of basic understanding.
In my project i have tickets and ticket snaps. Its a one to many connection.
So every ticket can have multiple Ticketsnaps. The Ticketsnaps are like chat pieces of this ticket.
They just have the ticket_id the user_id and the text.

Now i want to show the ticket and the user should be able to add a ticketsnap direktly in the ticket view.

I added to the tickets->template this piece from ticketsnaps ->add

<div class="related">
     <?= $this->Form->create($ticketSnap) ?>
     <fieldset>
              <legend><?= __('Add Ticket Snap') ?></legend>
              <?php 
//                        echo $this->Form->control('ticket_id', ['options' => $tickets]);
//                        echo $this->Form->control('user_id', ['options' => $users]);
                          echo $this->Form->control('text'); 
               ?>
      </fieldset>
      <?= $this->Form->button(__('Submit')) ?>
      <?= $this->Form->end() ?>
</div>

of course the whole logic is not present here.
so do i have to copy the whole TicketsnapController code to the
TicketController or how do i proceed here?

Thank you! :pray:

James McDonald has a nice video explaining how this works:

2 Likes

:pray: Perfect, thank you so much Kevin!!!