Browse Source

fix(snippets): add name attribute to form

Josh Habdas 1 year ago
parent
commit
078ee4de30
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74
2 changed files with 7 additions and 5 deletions
  1. 2
    1
      layouts/partials/components/form.html
  2. 5
    4
      layouts/shortcodes/hackcss-form.html

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

@@ -1,4 +1,5 @@
1 1
 <form
2
+  {{ with .name }}name="{{ . }}" {{ end }}
2 3
   {{ with .action }}action="{{ . | safeURL }}" {{ end }}
3 4
   {{ with .enctype }}enctype="{{ . }}" {{ end }}
4 5
   {{ with .target }}target="{{ . }}" {{ end }}
@@ -6,6 +7,6 @@
6 7
   {{ if eq .novalidate "true" }}novalidate {{ end }}
7 8
   {{ if in (slice "on" "off") .autocomplete }}autocomplete="{{ .autocomplete }}" {{ end }}
8 9
   {{ if in (slice "get" "post") .method }}method="{{ .method }}" {{ end }}
9
-  class="form{{ if in (slice "success" "error" "warning") .state }} form-{{ .state | safeHTMLAttr }}{{ end }}{{ with .class }} {{ . }}{{ end }}">
10
+  class="form{{ with .class }} {{ . }}{{ end }}">
10 11
   {{ .body }}
11 12
 </form>

+ 5
- 4
layouts/shortcodes/hackcss-form.html View File

@@ -1,5 +1,5 @@
1 1
 <!-- {{/*
2
-HTML attributes: "accept-charset", "action", "enctype", "target", "novalidate", "method", "class", "autocomplete"
2
+HTML attributes: "name", "accept-charset", "action", "enctype", "target", "novalidate", "method", "class", "autocomplete"
3 3
 
4 4
 Available states: [default], "success", "error", "warning"
5 5
 Possible methods: "get", "post"
@@ -10,8 +10,8 @@ Basic usage:
10 10
   {{< hackcss-textinput >}}
11 11
 {{< /hackcss-form >}}
12 12
 
13
-Targeting self with text input and autocomplete disabled:
14
-{{< hackcss-form autocomplete="disabled" >}}
13
+Named targeting self with text input and autocomplete disabled:
14
+{{< hackcss-form name="search" autocomplete="disabled" >}}
15 15
   {{< hackcss-textinput name="query" >}}
16 16
 {{< /hackcss-form >}}
17 17
 
@@ -27,6 +27,7 @@ Specify allowed encodings:
27 27
 
28 28
 */}} -->
29 29
 {{ $accept_charset := .Get "acceptcharset" }}
30
+{{ $name := .Get "name" }}
30 31
 {{ $action := .Get "action" }}
31 32
 {{ $enctype := .Get "enctype" }}
32 33
 {{ $target := .Get "target" }}
@@ -35,4 +36,4 @@ Specify allowed encodings:
35 36
 {{ $method := .Get "method" }}
36 37
 {{ $class := .Get "class" }}
37 38
 {{ $body := .Inner }}
38
-{{ partial "components/form.html" (dict "accept_charset" $accept_charset "action" $action "enctype" $enctype "target" $target "novalidate" $novalidate "method" $method "class" $class "body" $body) }}
39
+{{ 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) }}

Loading…
Cancel
Save