Controller/ContactFormController.php
public function formAction(Request $request)
    {
        $useAjax = $request->get('use_ajax', true);

        $inquiry = new ContactInquiry();

        $form = $this->createForm(ContactFormType::class, $inquiry, array(
            'action' => $this->generateUrl('C33s_ContactFormBundle_form'),
            'method' => 'POST',
            'attr' => array(
                'id' => 'c33s_contact_form',
            ),
        ));

        $message = $request->get('success_message', false);
        $form->handleRequest($request);

        if ($form->isValid()) {
            if ($this->container->getParameter('c33s_contact_form.database.enabled') === true) {
                $inquiry->save();
            }
            if ($this->container->getParameter('c33s_contact_form.email.enabled') === true) {
                $this->sendEmails($inquiry);
            }

            return array('form' => null, 'use_ajax' => $useAjax, 'success_message' => null, 'success' => true);
        }

        return array('form' => $form->createView(), 'use_ajax' => $useAjax, 'success_message' => $message, 'success' => false);
    }
public function formAction(Request $request)
    {
        $useAjax = $request->get('use_ajax', true);

        $inquiry = new ContactInquiry();

        $form = $this->createForm(ContactFormType::class, $inquiry, array(
            'action' => $this->generateUrl('C33s_ContactFormBundle_form'),
            'method' => 'POST',
            'attr' => array(
                'id' => 'c33s_contact_form',
            ),
        ));

        $message = $request->get('success_message', false);
        $form->handleRequest($request);

        if ($form->isValid()) {
            if ($this->container->getParameter('c33s_contact_form.database.enabled') === true) {
                $inquiry->save();
            }
            if ($this->container->getParameter('c33s_contact_form.email.enabled') === true) {
                $this->sendEmails($inquiry);
            }

            return array('form' => null, 'use_ajax' => $useAjax, 'success_message' => null, 'success' => true);
        }

        return array('form' => $form->createView(), 'use_ajax' => $useAjax, 'success_message' => $message, 'success' => false);
    }
@Route("/contact_form/show", name="C33s_ContactFormBundle_form")
@Template()

@return \Symfony\Component\HttpFoundation\Response