php - laravel 8,如何使用 post 方法显示来自 FORM 的数据?
问题描述
我的路线:
Route::resource('/posts',PostsControllerWithAll::class);
我的表格: 我尝试从这个表格中读取给定的数据
<form method="POST" action="{{ action('PostsControllerWithAll@store') }}">
@csrf
<input type="text" name="title" placeholder="enter title">
<input type="submit" name="submit">
</form>
我的控制器:
public function create()
{
return view("posts.create");
}
public function store(Request $request)
{
return $request->all();
}
这是我的路线清单
解决方案
尝试使用命名路线,就像您在打印屏幕上显示的那样。
<form method="POST" action="{{ action('posts.store') }}">...</form>
要验证存储方法上的字段值,请使用 dd($request->all()) 这转储变量并死掉,很高兴看到预期的结果。
推荐阅读
- python - 弹性搜索 DSL。在聚合内构建边界框过滤器
- c# - Cosmos db 上的延续令牌格式无效
- r - 使用“ml_create_dummy_variables”创建虚拟变量 SparkR
- javascript - 如何从一个点到另一个点滚动页面
- amazon-web-services - aws amplify push 说“请求时间和当前时间之间的差异太大”
- html - 完整的日历中心标题不起作用它显示正确
- java - 在自定义视图中为标签找到了意外的命名空间前缀“app”,但实际上是正确的
- reactjs - React/Redux 可以在前端操作存储状态吗?
- docker-compose - Docker-compose EMQX 桥接(MQTT 桥接)设置
- python - 在 Mac 上使用 Python 中的 comtypes 将 MS Office 文件 docx、ppt、xlsx 转换为 PDF 的问题-