Browse Source

Added functionality to change the page title when rendering pseudo pages. Added functionality to get an individual form field value.

Wirecog 7 years ago
parent
commit
517639528f
2 changed files with 14 additions and 0 deletions
  1. 9
    0
      basicform.go
  2. 5
    0
      template.go

+ 9
- 0
basicform.go View File

@@ -40,6 +40,15 @@ func (c *BasicForm) SetFields(fields map[string]string) {
40 40
 	c.fields = fields
41 41
 }
42 42
 
43
+func (c *BasicForm) GetFieldValue(key string) string {
44
+
45
+	if _, ok := c.fields[key]; ok {
46
+		return c.fields[key]
47
+	} else {
48
+		return ""
49
+	}
50
+}
51
+
43 52
 func (c *BasicForm) SetErrors(errors map[string]string) {
44 53
 	c.errors = errors
45 54
 }

+ 5
- 0
template.go View File

@@ -49,6 +49,7 @@ type RenderParams struct {
49 49
 	ShouldPopulateRenderedContent bool
50 50
 	RenderedContent               string
51 51
 	ShouldSkipFinalRenderStep     bool
52
+	PageTitle                     string
52 53
 }
53 54
 
54 55
 func (t *Template) GetTemplateType() int8 {
@@ -143,6 +144,10 @@ func (t *Template) RenderTemplateOnClient(params *RenderParams) {
143 144
 		params.Element.AppendChild(div)
144 145
 	}
145 146
 
147
+	if params.PageTitle != "" && params.ShouldPopulateRenderedContent == false {
148
+		dom.GetWindow().Document().Underlying().Set("title", params.PageTitle)
149
+	}
150
+
146 151
 }
147 152
 
148 153
 func (t *Template) RenderTemplateOnServer(params *RenderParams) {