Laravel表单传值

时间:2022-05-04 16:10:38

仔细阅读过Laravel官方文档的就不用看啦~

整理下之前遇到的关于Laravel表单的一些小问题

表单传值无法传过去,因为laravel做了表单的防护

只需要将{{ csrf_field() }}放在表单中即可

<form method="POST" action="{{route('posts.store')}}">
{{csrf_field()}}
<input type="text" name="title"/>
<input type="text" name="author[name]"/>
<input type="text" name="author[desc]"/>
<textarea cols="20" rows="5" name="body"></textarea>
<button type="submit">submit</button>
</form>