-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextarea.go
43 lines (32 loc) · 948 Bytes
/
textarea.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package dhtmlform
import (
"github.com/mitoteam/dhtml"
)
const textareaControlKind = "textarea"
func init() {
RegisterFormControlHandler(textareaControlKind, &FormControlHandler{
RenderF: func(control *FormControlElement) (out dhtml.HtmlPiece) {
rootTag := dhtml.Div()
if control.IsError() {
rootTag.Styles(errorBlockStyle)
}
if !control.GetLabel().IsEmpty() {
rootTag.Append(control.renderLabel())
}
textareaTag := dhtml.NewTag("textarea").Id(control.GetId()).Attribute("name", control.GetName()).
Append(control.GetValue())
if control.GetPlaceholder() != "" {
textareaTag.Attribute("placeholder", control.GetPlaceholder())
}
rootTag.Append(textareaTag)
if !control.GetNote().IsEmpty() {
rootTag.Append(control.renderNote())
}
out.Append(rootTag)
return out
},
})
}
func NewTextarea(name string) *FormControlElement {
return NewFormControl(textareaControlKind, name)
}