Browse Source

feat(shortcodes): add id attribute for forms

allows forms ownership by controls outside form with form attribute
Josh Habdas 10 months ago
parent
commit
10f10244b7
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74
2 changed files with 4 additions and 2 deletions
  1. 1
    0
      layouts/partials/components/form.html
  2. 3
    2
      layouts/shortcodes/hackcss-form.html

+ 1
- 0
layouts/partials/components/form.html View File

@@ -1,4 +1,5 @@
1 1
 <form
2
+  {{ with .id }}id="{{ . }}" {{ end }}
2 3
   {{ with .name }}name="{{ . }}" {{ end }}
3 4
   {{ with .action }}action="{{ . | safeURL }}" {{ end }}
4 5
   {{ with .enctype }}enctype="{{ . }}" {{ end }}

+ 3
- 2
layouts/shortcodes/hackcss-form.html View File

@@ -1,5 +1,5 @@
1 1
 <!-- {{/*
2
-HTML attributes: "name", "accept-charset", "action", "enctype", "target", "novalidate", "method", "class", "autocomplete"
2
+HTML attributes: "id", "name", "accept-charset", "action", "enctype", "target", "novalidate", "method", "class", "autocomplete"
3 3
 
4 4
 Possible methods: "get", "post"
5 5
 Possible autocompletes: "on", "off"
@@ -26,6 +26,7 @@ Specify allowed encodings:
26 26
 
27 27
 */}} -->
28 28
 {{ $accept_charset := .Get "acceptcharset" }}
29
+{{ $id := .Get "id" }}
29 30
 {{ $name := .Get "name" }}
30 31
 {{ $action := .Get "action" }}
31 32
 {{ $enctype := .Get "enctype" }}
@@ -35,7 +36,7 @@ Specify allowed encodings:
35 36
 {{ $method := .Get "method" }}
36 37
 {{ $class := .Get "class" }}
37 38
 {{ $body := .Inner }}
38
-{{ partial "components/form.html" (dict "name" $name "accept_charset" $accept_charset "action" $action "enctype" $enctype "target" $target "novalidate" $novalidate "method" $method "class" $class "body" $body) }}
39
+{{ partial "components/form.html" (dict "id" $id "name" $name "accept_charset" $accept_charset "action" $action "enctype" $enctype "target" $target "novalidate" $novalidate "method" $method "class" $class "body" $body) }}
39 40
 {{ if eq "false" $autocomplete }}
40 41
   <p>{{ partial "components/alert.html" (dict "type" "error" "body" (errorf "Invalid autocomplete value for form. Did you mean \"off\" instead of %q?" $autocomplete)) }}</p>
41 42
 {{ end }}

Loading…
Cancel
Save