constructors.go 787 B

1234567891011121314151617181920212223242526272829
  1. package form
  2. ///* Generate new CharField field with type text */
  3. //func NewCharField(Name string, Label *string, Value *string, Class *string, Validators *ValidatorsList) FormField {
  4. // strFromPtr := func(str *string) (s string) {
  5. // if str != nil {
  6. // s = *str
  7. // }
  8. // return
  9. // }
  10. // return FormField{Name, strFromPtr(Label), strFromPtr(Value), strFromPtr(Class), nil, Validators}
  11. //}
  12. func strFromPtr(str *string) (s string) {
  13. if str != nil {
  14. s = *str
  15. }
  16. return
  17. }
  18. /* Generate new CharField field with type text */
  19. func NewCharField(Name string, Value *string) *FormField {
  20. return &FormField{Name, "", strFromPtr(Value), "", nil, nil}
  21. }
  22. /* Generate new CharField field with type password */
  23. func NewPasswordField(Name string) *FormField {
  24. return NewCharField(Name, nil)
  25. }