-1
我是Symfony2中的新手。我的问题是:我想将Twig格式的值传递给数据库。 控制器:从Twig形式传递变量
public function createAction()
{
$product = new Product();
$product->setName('name');
$product->setPrice('price');
$product->setDescription('description');
$em = $this->getDoctrine()->getEntityManager();
$em->persist($product);
$em->flush();
return new Response('Izveidots produkts id '.$product->getId());
}
我想从形式,而不是使用恒定的人(“姓名”,“价格”)的使用值。该视图:
<form action="{{ path('blogger_blog_create') }}" method="post" {{ form_enctype(form) }}>
{{ form_errors(form) }}
{{ form_row(form.name)}}
{{ form_row(form.price) }}
{{ form_row(form.description) }}
{{ form_rest(form) }}
<input type="submit" />
</form>
我想弄明白了几个小时。