-
Notifications
You must be signed in to change notification settings - Fork 6
/
textbox.go
31 lines (27 loc) · 889 Bytes
/
textbox.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
package generator
import (
"fmt"
generator2 "github.com/goradd/goradd/codegen/generator"
"github.com/goradd/goradd/pkg/orm/db"
generator3 "github.com/goradd/goradd/pkg/page/control/generator"
)
func init() {
generator2.RegisterControlGenerator(Textbox{}, "github.com/goradd/goradd/pkg/bootstrap/control/Textbox")
}
// Textbox describes the textbox to the connector dialog and code generator
type Textbox struct {
generator3.Textbox // base it on the built-in generator
}
func (d Textbox) GenerateCreator(ref interface{}, desc *generator2.ControlDescription) (s string) {
col := ref.(*db.Column)
s = fmt.Sprintf(
`%s.TextboxCreator{
ID: p.ID() + "-%s",
MaxLength: %d,
ControlOptions: page.ControlOptions{
IsRequired: %#v,
DataConnector: %s{},
},
}`, desc.Package, desc.ControlID, col.MaxCharLength, !col.IsNullable, desc.Connector)
return
}