LoginSignup
0
0

【PUG】input(type="hidden")とlabelの組み合わせ問題

Posted at

はじめに

PUGでマークアップ中にinput(type="hidden")タグを使う場面があった。

input(type="hidden")だけだとエラーになる

PUGで下記のようなhiddenを記述する。

input(type="hidden", value="hoge")

これだけだと「inputタグはlabelタグが必要」というエラーが発生する。

HTML的にはhiddenやinputタグにlabelは必ずしも必要ではない。
ただ、PUGではlabelがないと怒られてしまう。
なので、labelタグを下記のように設定した。

label(for="hoge")
    input(type="hidden", value="hoge", id="hoge")

しかしこうすると「非表示ではないinputにはlabelが必要」というエラーが発生する。

error: The value of the "for" attribute of the "label" element must be the ID of a non-hidden form control.

input(type="hidden")は表示されないタグなのでこれの対象になるのだが、消すと最初のエラーが発生する。

解決方法が不明

「lintの除外ルールとして記載する」など、いろんなソースを見てみたがいまだに解決方法は不明。
ひと段落したら再度調査するが上記の記述をする場合は注意。

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