I made my first steps in Symfony 3.x. I tried to make a simple small form, but I am getting an error message which I don't understand.
Variable "read_only" does not exist in form_div_layout.html.twig at line 323
My PHP:
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
class StartController extends Controller
{
public function testMeAction(){
$form = $this->createFormBuilder()
->add('task',TextType::class)
->getForm();
return $this->render('psychoform.html.twig',array(
'form'=>$form->createView()
));
}
}
My Template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
{{ form_start(form) }}
{{ form_end(form) }}
</body>
</html>
What am I doing wrong? Thank you for your help. -Micha
"read_only" has been deprecated in Symfony 2.8, and instead should use read only as an attribute.
The issue must have occurred because of old symfony or twig version. Try updating both.