Tutorial-First-Application
Tutorial-First-Application copied to clipboard
Tickets page not working as expected
After installing the project in a sub directory the tickets page it did not work. It was not possible to add new items, the URL to add new items is wrong. When I changed it manually it worked. To solve it “easy way” I used a virtual site, but that is workable on the long run.
After some testing I removed the virtual site, but this time I was able to view the details without any problems. Then I note that view detail uses pathFor, but that is not done for Add new ticket. The URL for new tickets is hard coded.
From tickets.phtml
Line 9
<p><a href="/ticket/new">Add new ticket</a></p>
line 31
<a href="<?=$router->pathFor('ticket-detail', ['id' => $ticket->getId()])?>">view</a>
Is this done on purpose?
I solved it this way:
file index.php line 72 change
});
to
})->setName('ticket-new');
file tickets.phtml line 9 change
<p><a href="/ticket/new">Add new ticket</a></p>
to
<p><a href="<?=$router->pathFor('ticket-new')?>">Add new ticket</a></p>
Is this the way to go, or should it be done in an other way?
I think it should use pathFor as you show.
This will need an update to the text of the tutorial as well as the source code.