0

So I have this controller

/**
 * @Route("/submit", name="submit")
 */
public function submitAction(Request $request) {
    var_dump($request->getMethod());
}

Now If I create the form in my twig template with

<form action="{{ path('submit') }}" method="post">
  <input type="text" name="text">
  <button type="submit">Submit</button>
</form>

getMethod returns POST

But If I do the exact same thing, but using the full url in the action, like this

<form action="http://domain.my/submit" method="post">

The the getMethod returns GET instead.

How do I fix this?

2
  • 1
    So, if I understood well, you are trying to send request from another website ? Do you have any exception ? did you check if CORS are allowed ? Commented Jun 26, 2015 at 2:00
  • Correct, and it is intended for this one controller - Is it possible to turn CORS off for this controller? Commented Jun 26, 2015 at 3:27

1 Answer 1

1

Well very simple

https://github.com/nelmio/NelmioCorsBundle

nelmio_cors:
    paths:
        '^/xml/':
            allow_origin: ['*']
            allow_methods: ['POST']
Sign up to request clarification or add additional context in comments.

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.