Kotlin / kotlinx.html

Kotlin DSL for HTML
Apache License 2.0
1.61k stars 131 forks source link

Add htmlFor parameter to label element #203

Open JohannesOehm opened 1 year ago

JohannesOehm commented 1 year ago

Currently, you have to do:

checkBoxInput(classes = "form-check-input", name = "myName") {
    id = "myId"
    value = "myValue"
}

label(classes="myclass") {
  htmlFor="myId"
  +"Check me" 
}

However, a label without for attribute is not very common. It should be a parameter, so that it is much more concise to write:

label(classes = "myclass",  htmlFor = "myId") {
  +"Check me" 
}
martinstender commented 1 year ago

Can't you just go: label (classes = "") { attributes["for"] = "myId" +"Check me" } ?

JohannesOehm commented 1 year ago

thats my first solution, but written without linebreak.