0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

laravel collective 間違いやすい箇所

Last updated at Posted at 2021-10-20

なんでもtokenを書くべきじゃない

Form::open(['url' => 'home'])

//↓HTMLではこう書かれていることになる
<form method="POST" action="http://localhost:3000/home" accept-charset="UTF-8">
<input name="_token" type="hidden" value="eAFowzR2efsBNQYrVzQ4VymRbYQB2afVyEDijzqd">

自動的にCSRFトークンが追加されて出力される。

そのためこの直後に

{{Form::token()}}

は必要ない

重複していた
{{Form::token()}}を書くとf12で調べると↓ができてた(無駄に)

<input name="_token" type="hidden" value="yaSSZowIRXjlDCEpHuO2wasNlcf4U3moVPG4lOE0">

意外に間違われているlabel

//HTML
<label for="name">氏名</label>

# Formファサード
{{Form::label('name','氏名')}}

第1引数 は"関連付けフォームの指定 for(input要素のid)"
→nameではない

input要素にid属性を設定し、label要素のfor属性でinput要素のidを指定する

↓参考記事
https://style.potepan.com/articles/20037.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?