2

I send some data by POST.

For example: http://.../?tag[]=1&tag[]=2

I cant receive tag varible in controller, I tried to do something like this:

$this->get('request')->get('tag');

But I receive null.

Whats wrong?

2 Answers 2

2

If you are sending data as you mentioned via URL, it is a GET request.

public function exampleAction(Request $request)
{
    $tagPost=$request->request->get('tag');     //from $_POST[]
    $tagGet=$request->query->get('tag');        //from $_GET[]
    var_dump($tagPost,$tagGet);
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, you are right. But I think it was Advanced REST for Google Chrome extension error. Now I receive tags.
2

try:

$this->get('request')->request->get('tag');

instead of:

$this->get('request')->get('tag');

EDIT: IF you http method is GET (instead of POST), you can try with:

$this->get('request')->query->get('tag');

Check here for further detail

hope this help

1 Comment

Thanks, you are right. But I think it was Advanced REST for Google Chrome extension error. Now I receive tags.

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.