0

I have a page with two forms that can be submitted separately. I tried this approach to check which form was submitted, but $request->request is always an empty array. What am I missing?

public function submitAction(Request $request) {
        $dm = $this->get('doctrine_mongodb')->getManager();
        $processes = $dm->getRepository('MyCoreBundle:Process')->findAll();

        $formClients = $this->createForm(new FiltersFormType(), $processes);
        $formClients->handleRequest($request);

        $formSuppliers = $this->createForm(new SupplierFormType(), $processes);
        $formSuppliers->handleRequest($request);
}

Edit: it's being posted via GET

1
  • 2
    Can you paste also your form pls Commented Aug 26, 2014 at 9:04

2 Answers 2

2

you can try something like:

public function submitAction() {

    $request = $this->container->get('request');

    (...)

}
Sign up to request clarification or add additional context in comments.

1 Comment

I'm sorry for not providing enough information before, but the form is submitted via GET. I'm now using $request->query->has($formClients->getName()) to check if my key exists, but it still doesn't work. This query contains a ['parameters':protected] which then contains the form name.. I don't understand how to reach it, because this parameters is not accessible.
0

Here's how I solved it, to check if a key is present, when posting via GET:

$request->query->get($formClients->getName())

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.