package components import ( "fmt" "html/template" "strings" "github.com/GoAdminGroup/go-admin/modules/config" "github.com/GoAdminGroup/go-admin/modules/language" "github.com/GoAdminGroup/go-admin/modules/utils" form2 "github.com/GoAdminGroup/go-admin/plugins/admin/modules/form" "github.com/GoAdminGroup/go-admin/template/types" "github.com/GoAdminGroup/go-admin/template/types/form" ) type FormAttribute struct { Name string Id string Header template.HTML Content types.FormFields ContentList []types.FormFields Layout form.Layout TabContents []types.FormFields TabHeaders []string Footer template.HTML Url string FieldsHTML template.HTML Method string PrimaryKey string Ajax bool AjaxSuccessJS template.JS AjaxErrorJS template.JS HeadWidth int InputWidth int HiddenFields map[string]string Title template.HTML OperationFooter template.HTML Prefix string CdnUrl string Horizontal bool types.Attribute } func (compo *FormAttribute) SetHeader(value template.HTML) types.FormAttribute { compo.Header = value return compo } func (compo *FormAttribute) SetPrimaryKey(value string) types.FormAttribute { compo.PrimaryKey = value return compo } func (compo *FormAttribute) SetHorizontal(value bool) types.FormAttribute { compo.Horizontal = value return compo } func (compo *FormAttribute) SetContent(value types.FormFields) types.FormAttribute { compo.Content = value return compo } func (compo *FormAttribute) SetId(id string) types.FormAttribute { compo.Id = id return compo } func (compo *FormAttribute) SetAjax(successJS, errorJS template.JS) types.FormAttribute { if successJS != template.JS("") && errorJS != template.JS("") { compo.Ajax = true compo.AjaxErrorJS = errorJS compo.AjaxSuccessJS = successJS } return compo } func (compo *FormAttribute) SetTabContents(value []types.FormFields) types.FormAttribute { compo.TabContents = value return compo } func (compo *FormAttribute) SetTabHeaders(value []string) types.FormAttribute { compo.TabHeaders = value return compo } func (compo *FormAttribute) SetHeadWidth(width int) types.FormAttribute { if width > 0 { if width > 12 { width = 12 } compo.HeadWidth = width } return compo } func (compo *FormAttribute) SetInputWidth(width int) types.FormAttribute { if width > 0 { if width > 12 { width = 12 } compo.InputWidth = width } return compo } func (compo *FormAttribute) SetFieldsHTML(html template.HTML) types.FormAttribute { compo.FieldsHTML = html return compo } func (compo *FormAttribute) SetFooter(value template.HTML) types.FormAttribute { compo.Footer = value return compo } func (compo *FormAttribute) SetLayout(layout form.Layout) types.FormAttribute { compo.Layout = layout return compo } func (compo *FormAttribute) SetPrefix(value string) types.FormAttribute { compo.Prefix = value return compo } func (compo *FormAttribute) SetUrl(value string) types.FormAttribute { compo.Url = value return compo } func (compo *FormAttribute) SetHiddenFields(fields map[string]string) types.FormAttribute { compo.HiddenFields = fields return compo } func (compo *FormAttribute) SetMethod(value string) types.FormAttribute { compo.Method = value return compo } func (compo *FormAttribute) SetTitle(value template.HTML) types.FormAttribute { compo.Title = value return compo } func (compo *FormAttribute) GetDefaultBoxHeader(hideBack bool) template.HTML { if hideBack { return template.HTML(fmt.Sprintf(`