I try to learn php/twig from a tutorial video and I tried to recreate the exercise but can't get back data from a simple form. The name variable in the action is always null. Everything else works. I looked through it multiple times but did everything like in the video. Some help would be really appreciated, thank you!
The action:
public function AddAction(Request $request) : Response{
$name = $request->request->get("name"); //always null
if ($name){
file_put_contents($this->fname, $name,FILE_APPEND);
$this->addFlash("notice","ITEM ADDED");
}
else{
$this->addFlash("notice","DATA ERROR");
}
return $this->redirectToRoute("list");
}
The form:
{% block body %}
<form action="{{ path('add') }}" mehod="POST">
<table>
<tr><td>Name of new item:</td>
<td><input type="text" name="name"/></td></tr>
<tr><td></td>
<td colspan="2"><input type="submit" value="SEND"/></td></tr>
</table>
</form>
{% endblock %}