Example #1
0
func (ø *FormHandler) AddSubmitButton(value string) (el *h.Element) {
	el = INPUT(
		h.Class("submit"),
		h.Class("btn"),
		h.Class("btn-primary"),
		h.Attr("type", "submit", "value", value))
	ø.Element.Add(el)
	return
}
Example #2
0
// sets the infos of the inner Field tag
func (ø *Field) setFieldInfos() {
	fs := ø.Element.Fields()
	if len(fs) == 0 {
		panic("got no form Field in " + ø.Element.String())
	}
	fs[0].Add(h.Class("field"), h.Id(ø.Name), h.Attr("name", ø.Name))
	if ø.Required {
		fs[0].Add(h.Attr("required", "required"))
		fs[0].AddClass(h.Class("required"))
	}
	ø.setLabelInfos()
}
Example #3
0
func (ø *Field) setLabelInfos() {
	label := ø.Element.Any(h.Tag("label"))
	if label != nil {
		label.Add(h.Attr("for", ø.Name))
		if ø.Required {
			label.Add(h.Class("required"))
		}
	}
}
Example #4
0
func GetElement(in *pgsql.Field) (out *h.Element) {
	if in.Selection != nil {
		return SELECT()
	}
	if pgsql.IsVarChar(in.Type) {
		return INPUT(h.Attr("type", "text"))
	}

	if in.Type == pgsql.BoolType {
		return SELECT(
			OPTION(h.Attr("value", "true"), "true"),
			OPTION(h.Attr("value", "false"), "false"),
		)
	}

	switch in.Type {
	case pgsql.TextType:
		return TEXTAREA()
	case pgsql.XmlType:
		return TEXTAREA(h.Class("xml"))
	case pgsql.HtmlType:
		return TEXTAREA(h.Class("html"))
	case pgsql.IntType:
		return INPUT(h.Attr("type", "number"))
	case pgsql.UuidType:
		if in.ForeignKey != nil {
			return INPUT(h.Attr("type", "text", "fkey", in.ForeignKey.Table.Name), h.Class("foreign-key"))
		}
		return INPUT(h.Attr("type", "text"))
	case pgsql.DateType:
		return INPUT(h.Attr("type", "text"), h.Class("date"))
	case pgsql.TimeType:
		return INPUT(h.Attr("type", "time"))
	}
	return INPUT(h.Attr("type", "text"))
}
Example #5
0
func (ø *TableForm) getElement(in *pgsql.Field) (out *h.Element) {
	if in.Selection != nil {
		ø.afterCreation = append(ø.afterCreation, func(tf *TableForm) {
			sell := []interface{}{}
			for _, ss := range in.Selection {
				sell = append(sell, ss)
			}
			tf.Selection(in.Name, sell...)
		})
		return SELECT()
	}
	if pgsql.IsVarChar(in.Type) {
		return INPUT(h.Attr("type", "text"))
	}

	if in.Type == pgsql.BoolType {
		return SELECT(
			OPTION(h.Attr("value", "true"), "true"),
			OPTION(h.Attr("value", "false"), "false"),
		)
	}

	switch in.Type {
	case pgsql.TextType:
		return TEXTAREA()
	case pgsql.XmlType:
		return TEXTAREA(h.Class("xml"))
	case pgsql.HtmlType:
		return TEXTAREA(h.Class("html"))
	case pgsql.UuidType:
		if in.ForeignKey != nil {
			return INPUT(h.Attr("type", "text", "fkey", in.ForeignKey.Table.Name), h.Class("foreign-key"))
		}
		return INPUT(h.Attr("type", "text"))
	case pgsql.IntType:
		return INPUT(h.Attr("type", "number"))
	case pgsql.DateType:
		return INPUT(h.Class("date"), h.Attr("type", "text"))
	case pgsql.TimeType:
		return INPUT(h.Attr("type", "time"))
	}
	return INPUT(h.Attr("type", "text"))

	/*
	 input[type="password"]:focus,
	 input[type="datetime"]:focus,
	 input[type="datetime-local"]:focus,
	 input[type="date"]:focus,
	 input[type="month"]:focus,
	 input[type="time"]:focus,
	 input[type="week"]:focus,
	 input[type="number"]:focus,
	 input[type="email"]:focus,
	 input[type="url"]:focus,
	 input[type="search"]:focus,
	 input[type="tel"]:focus,
	 input[type="color"]:focus,
	 .uneditable-input:focus
	*/

}