Krzysztof Płonka Magento front-end
Temat: Obsługa formularzy w Symfony 2
Mam taki formularz<form action="{{path('admin_comment_new', {'slug':a.slug})}}" method="post" novalidate >
<textarea></textarea>
<div class="form-actions">
<input class="btn btn-primary" type="submit" value="Komentuj"/>
</div>
</form>
controler obsługujący go:
/**
* @Secure(roles=" ")
* @Route("../article/{slug}", name="admin_comment_new")
* @Template
*/
public function newAction() {
$form = $this->container->get('form.factory')->create(new CommentFormType(), array());
$form_handler = new CommentFormHandler(
$form,
$this->container->get('request'),
$this->container->get('doctrine.orm.entity_manager'));
$commentform = new CommentForm();
$commentform->setComment(new Comment());
$process = $form_handler->process($commentform);
if ($process) {
$this->setFlash('aviso1', 'Komentarz dodany');
}
return array(
'form' => $form->createView(),
);
}
Jak je połączyć żeby zapisywało komentarze z textarea do tabeli comments ???