A typo on the menu: the “Elven Mushroom Pie” has become the “Elven Mushrom Pie”. And the stew's price has to go up (the grumpy dwarf is demanding a raise). Bruna wants to be able to edit a dish without going through the console.
Good news: PlatType works just as well for creating as for editing. You only need to bind it to an existing dish.
Your mission
- Add a
modifierPlat()(edit dish) action toCuisineControlleron/kitchen/dish/{slug}/edit(routeapp_modifier_plat):- the dish is found from the slug in the URL (404 if it does not exist);
- the
PlatTypeform is displayed, prefilled; - if it is submitted and valid: save, add the flash message “The dish has been updated.”, then redirect to the dish page.
- Write the
cuisine/modifier.html.twigtemplate, with a “Save” button. - On a dish page, add an “Edit” link.
The slug does not change when the name changes: links to the dish page that have already been shared must stay valid.
Reminder
An object loaded from the database is tracked by Doctrine: on flush(), its changes are written. persist() is only for new objects.