I have one table name Blog bellow is it's structure.
FieldName Type
Id int(5)
blog_title string(255)
blog_url string(255)
blog_desc text
image string(255)
tags string(255)
blog_created_at Date
blog_status string(1)
i have created one form for this table in controller.
public function addAction()
{
$entity = new Blog();
$form = $this->createFormBuilder()
->add('blog_title')
->add('blog_desc' ,'textarea')
->add('blog_url')
->add('image')
->add('tags')
->add('blog_status')
->getForm();
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if ($form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('admin_index'));
}
}
return $this->render('AdminBlogBundle:default:add.html.twig',array(
'form' => $form->createView(),
));
}
I want to enter the value of this form to my database but it gives me error of
An exception occurred while executing 'INSERT INTO Blog (blog_title, blog_desc,
blog_url, image, tags, blog_created_at, blog_status) VALUES (?, ?, ?, ?, ?, ?, ?)'
with params {"1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null}:
all the value which i am posting from the form am getting in object array of request which i m getting bye calling the print_r($request); but while binding it is giving me this error. so pls help me.