I have Symfony app and I try to submit a simple form to action function which..and obviously my annotations are wrong but I don't know how to fix them. Here is the full error
[Syntax Error] Expected Value, got 'POST' at position 58 in method AppBundle\Controller\ProjectController::showAction() in C:\xampp\htdocs\TaskManager\src\AppBundle/Controller/ (which is being imported from "C:\xampp\htdocs\TaskManager\app/configouting.yml").
Here is the form I am trying to submit in show.html.twig
<form method="post">
<input type="submit" name="approve" value="Approve">
<input type="submit" name="reject" value="Reject">
</form>
The reason behind it is that I have a single type of user which can Approve or Reject a project. This user should not go to edit page just to change those two fields. Instead it should click two buttons and the values should change without him doing anything else. My idea is to have this code in the showAction()
-
if (isset($_POST['approve'])) {
$project->setApproved(true);
$project->setRejected(false);
}
elseif (isset($_POST['rejected'])) {
$project->setRejected(true);
$project->setApproved(false);
}
After I change those values I intend on flushing them so when the project is shown again it will be either Approved or Rejected. The key here is that there should be no fields. When I want to show a project I already have everything needed to flush it. Here are my annotations for the showAction() -
/**
* Finds and displays a project entity.
*
* @Route("/{id}", name="project_show")
* @Method("GET","POST")
*/
Just for comparison here are my annotations in editAction()
which works fine
/**
* Displays a form to edit an existing project entity.
*
* @Route("/{id}/edit", name="project_edit")
* @Method({"GET", "POST"})
*/
What do I need to be able to submit this one simple form in my showAction()
?