all repos — gomponents @ ceb0e8e26d0c0b2e96952176702efa442af55008

HTML components in pure Go

Add formxxx attributes (for <input type="submit"> element) (#241) Hello, A small patch to add the following attributes: - formaction - formenctype - formmethod - formnovalidate - formtarget These attributes are useful in `<input type="submit">` element: [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit#additional_attributes)

Stéphane Legrand
commit

ceb0e8e26d0c0b2e96952176702efa442af55008

parent

c366cfc3574daf7b31e4fa68790c29fc72f7b74b

2 files changed, 25 insertions(+), 0 deletions(-)

changed files
M html/attributes.gohtml/attributes.go
@@ -141,8 +141,28 @@ func For(v string) g.Node {
return g.Attr("for", v) } +func FormAction(v string) g.Node { + return g.Attr("formaction", v) +} + func FormAttr(v string) g.Node { return g.Attr("form", v) +} + +func FormEncType(v string) g.Node { + return g.Attr("formenctype", v) +} + +func FormMethod(v string) g.Node { + return g.Attr("formmethod", v) +} + +func FormNoValidate() g.Node { + return g.Attr("formnovalidate") +} + +func FormTarget(v string) g.Node { + return g.Attr("formtarget", v) } func Height(v string) g.Node {
M html/attributes_test.gohtml/attributes_test.go
@@ -21,6 +21,7 @@ {Name: "checked", Func: Checked},
{Name: "controls", Func: Controls}, {Name: "defer", Func: Defer}, {Name: "disabled", Func: Disabled}, + {Name: "formnovalidate", Func: FormNoValidate}, {Name: "loop", Func: Loop}, {Name: "multiple", Func: Multiple}, {Name: "muted", Func: Muted},
@@ -61,6 +62,10 @@ {Name: "enctype", Func: EncType},
{Name: "dir", Func: Dir}, {Name: "for", Func: For}, {Name: "form", Func: FormAttr}, + {Name: "formaction", Func: FormAction}, + {Name: "formenctype", Func: FormEncType}, + {Name: "formmethod", Func: FormMethod}, + {Name: "formtarget", Func: FormTarget}, {Name: "height", Func: Height}, {Name: "hidden", Func: Hidden}, {Name: "href", Func: Href},