0

Have a request that looks like this

ParameterBag {#362 ▼
  #parameters: array:1 [▼
    "form" => array:5 [▼
      "titre" => "new b"
      "prix" => "4444"
      "slug" => "with-different-slug"
      "publier" => "unpub"
      "Modifier" => ""
    ]
  ]
}

How can I use the $post = Request::createFromGlobals(); $post->request->has() on those nested properties?

1 Answer 1

3

ParameterBag's has function does not support deep check. It is just an array_key_exists call.

You could use get with $deep parameter set to true.

E.g.:

$post = Request::createFromGlobals();
$post->request->get('form[titre]', null, true);

It will return null (the second parameter), if the value does not exist.

EDIT:

This function however deprecated in 2.8.

Using paths to find deeper items in get is deprecated since version 2.8 and will be removed in 3.0. Filter the returned value in your own code instead.

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

1 Comment

Note: Finding deep items is deprecated since version 2.8, to be removed in 3.0.

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.