Searching for a Cakephp 5 Comments Tutorial

I’m trying to update my old cakephp website to version 5 and I don’t know how to handle the commenting interface. The way I designed it previously was by adding a comment element to the recipe view template and then handling the form submission in the RecipeController’s view method. This doesn’t work well because the form’s action is submitting to comment and not to view. So I added a comment method in my RecipeController but then I need two templates, one element template and one recipe comment template which makes no sense. I was hoping to find a tutorial but all of the tutorials I found were from version 2 or 3.

I am basically a new user so I don’t know much about this website but I am still learning about this website but still I can help you. So after my research i found this:
To update your CakePHP website to version 5 and manage the commenting interface effectively, create a new method like saveComment in your RecipeController to handle form submissions. Use CakePHP’s FormHelper to generate the comment form in your recipe view template and ensure the form’s action points to your new method. While specific CakePHP 5 tutorials are limited, you can adapt principles from earlier versions and refer to CakePHP documentation for guidance. This approach will help streamline your update and improve your commenting functionality.

Yes, you should post your “add comment” form to an “add comment” function, which will validate the data, save it, then redirect to the “view recipe” URL. See “Post Redirect Get” paradigm, this is exactly what Cake will bake for you.

I think the comment handling logic to a dedicated CommentController. This will keep your RecipeController focused on recipe-related actions.using AJAX to handle comment submissions. The form doesn’t need to leave the recipe view page, and you can dynamically update the comment section. Single template for rendering comments. Include this template in your recipe view and update it dynamically with AJAX responses.