本文介绍了Laravel表单发布到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Laravel的新手,在将数据发布到控制器时遇到麻烦.我找不到相应的文档.我想要在Laravel中实现与C#MVC类似的功能.
I am new to Laravel and I'm having trouble with posting data to a controller. I couldn't find the corresponding documentation. I want to something similar in Laravel that I do in C# MVC.
<form action="/someurl" method="post"> <input type="text" name="someName" /> <input type="submit"> </form>控制器
[HttpPost] public ActionResult SomeUrl(string someName) { ... }推荐答案
您应该使用route.
You should use route.
您的.html
<form action="{{url('someurl')}}" method="post"> <input type="text" name="someName" /> <input type="submit"> </form>在routes.php
Route::post('someurl', 'YourController@someMethod');,最后是YourController.php
public function someMethod(Request $request) { dd($request->all()); //to check all the datas dumped from the form //if your want to get single element,someName in this case $someName = $request->someName; }更多推荐
Laravel表单发布到控制器
发布评论