@@ -33,7 +33,7 @@ import (
33
33
"strings"
34
34
35
35
"github.com/coscms/forms/common"
36
- conf "github.com/coscms/forms/config"
36
+ "github.com/coscms/forms/config"
37
37
"github.com/coscms/forms/fields"
38
38
"github.com/webx-top/validation"
39
39
)
@@ -44,7 +44,7 @@ const (
44
44
GET = "GET"
45
45
)
46
46
47
- func NewWithConfig (c * conf .Config , args ... interface {}) * Form {
47
+ func NewWithConfig (c * config .Config , args ... interface {}) * Form {
48
48
form := New ()
49
49
form .Init (c , args ... )
50
50
return form
@@ -60,7 +60,7 @@ func NewWithConfigFile(m interface{}, configJSONFile string) *Form {
60
60
61
61
func New () * Form {
62
62
return & Form {
63
- FieldList : []conf .FormElement {},
63
+ FieldList : []config .FormElement {},
64
64
FieldMap : make (map [string ]int ),
65
65
ContainerMap : make (map [string ]string ),
66
66
Style : common .BASE ,
@@ -77,7 +77,7 @@ func New() *Form {
77
77
}
78
78
}
79
79
80
- func NewFromModel (m interface {}, c * conf .Config ) * Form {
80
+ func NewFromModel (m interface {}, c * config .Config ) * Form {
81
81
form := NewWithConfig (c , m )
82
82
form .SetModel (m )
83
83
form .ParseModel (m )
@@ -90,7 +90,7 @@ type Form struct {
90
90
Model interface {}
91
91
IngoreValid []string
92
92
93
- FieldList []conf .FormElement
93
+ FieldList []config .FormElement
94
94
FieldMap map [string ]int
95
95
ContainerMap map [string ]string
96
96
Style string
@@ -104,7 +104,7 @@ type Form struct {
104
104
valid * validation.Validation
105
105
labelFn func (string ) string
106
106
validTagFn func (string , fields.FieldInterface )
107
- config * conf .Config
107
+ config * config .Config
108
108
beforeRender []func ()
109
109
debug bool
110
110
OmitOrMustFieldsValue map [string ]bool //true:omit; false:must
@@ -192,9 +192,9 @@ func (f *Form) ValidTagFunc() func(string, fields.FieldInterface) {
192
192
return f .validTagFn
193
193
}
194
194
195
- func (f * Form ) Init (c * conf .Config , model ... interface {}) * Form {
195
+ func (f * Form ) Init (c * config .Config , model ... interface {}) * Form {
196
196
if c == nil {
197
- c = & conf .Config {}
197
+ c = & config .Config {}
198
198
}
199
199
f .config = c
200
200
if len (c .Theme ) == 0 {
@@ -209,7 +209,7 @@ func (f *Form) Init(c *conf.Config, model ...interface{}) *Form {
209
209
tmpl , ok := common .CachedTemplate (tpf )
210
210
if ! ok {
211
211
var err error
212
- tmpl , err = common .ParseFiles (common .CreateUrl (c .Template ))
212
+ tmpl , err = common .ParseFiles (common .LookupPath (c .Template ))
213
213
if err != nil {
214
214
log .Println (err )
215
215
}
@@ -304,7 +304,7 @@ func (f *Form) ParseModel(model ...interface{}) *Form {
304
304
}
305
305
flist , fsort := f .unWindStructure (m , `` )
306
306
for _ , v := range flist {
307
- f .Elements (v .(conf .FormElement ))
307
+ f .Elements (v .(config .FormElement ))
308
308
}
309
309
if len (fsort ) > 0 {
310
310
f .Sort (fsort )
@@ -613,7 +613,7 @@ func (f *Form) String() string {
613
613
}
614
614
615
615
// Elements adds the provided elements to the form.
616
- func (f * Form ) Elements (elems ... conf .FormElement ) {
616
+ func (f * Form ) Elements (elems ... config .FormElement ) {
617
617
for _ , e := range elems {
618
618
switch v := e .(type ) {
619
619
case fields.FieldInterface :
@@ -739,7 +739,7 @@ func (f *Form) Field(name string) fields.FieldInterface {
739
739
}
740
740
741
741
// Fields returns all field
742
- func (f * Form ) Fields () []conf .FormElement {
742
+ func (f * Form ) Fields () []config .FormElement {
743
743
return f .FieldList
744
744
}
745
745
@@ -757,7 +757,7 @@ func (f *Form) LangSet(name string) *LangSetType {
757
757
}
758
758
}
759
759
760
- func (f * Form ) NewLangSet (name string , langs []* conf .Language ) * LangSetType {
760
+ func (f * Form ) NewLangSet (name string , langs []* config .Language ) * LangSetType {
761
761
return LangSet (name , f .Style , langs ... )
762
762
}
763
763
@@ -785,7 +785,7 @@ func (f *Form) NewFieldSet(name string, label string, elems ...fields.FieldInter
785
785
func (f * Form ) SortAll (sortList ... string ) * Form {
786
786
elem := f .FieldList
787
787
size := len (elem )
788
- f .FieldList = make ([]conf .FormElement , size )
788
+ f .FieldList = make ([]config .FormElement , size )
789
789
var sortSlice []string
790
790
if len (sortList ) == 1 {
791
791
sortSlice = strings .Split (sortList [0 ], "," )
@@ -857,8 +857,8 @@ func (f *Form) Sort2Last(fieldsName ...string) *Form {
857
857
858
858
func (f * Form ) sortFields (index , oldIndex , endIdx , size int ) {
859
859
860
- var newFields []conf .FormElement
861
- oldFields := make ([]conf .FormElement , size )
860
+ var newFields []config .FormElement
861
+ oldFields := make ([]config .FormElement , size )
862
862
copy (oldFields , f .FieldList )
863
863
var min , max int
864
864
if index > oldIndex {
0 commit comments