mercredi 17 octobre 2018

Submitting form and set content type to application/json in Laravel

I have the following form:

<form action="/create" method="post" enctype="application/json">
 <input name="some_input" value="true"> 
 <input name="user.name" value="John">
 <input name="user.email" value="john@abc.com">
 <button>Save</button>
</form>

When I try to access the input values through the request, I am unable to access the values using the dot syntax as described in the documentation, for example:

request()->input('some_input') //true
request()->input('user.*') //null
request()->input('user.name') //null

My suspicion is that I am not setting the Content-type to application/json, but I am struggling to find information on how to do it correctly in this case.

Thank you for your help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire