Skip to content

Commit

Permalink
remove fieldValue fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
donseba committed Feb 28, 2023
1 parent 0b91fbe commit be342f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 5 additions & 3 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ var inputTpl = `<div>
<div class="mt-1">
{{ if eq .Type "dropdown" }}
<select {{with .Id}}id="{{.}}"{{end}} name="{{.Name}}" class="bg-white block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm">
{{ $value := .Value }}
{{ range $k, $option := .Values }}
<option value="{{$option.Id}}">{{$option.Name}}</option>
<option value="{{$option.Value}}" {{ if eq $value $option.Value }}selected{{ end }} {{ if eq $option.Disabled true }}disabled{{ end }}>{{$option.Name}}</option>
{{ end }}
</select>
{{ else if eq .Type "checkbox" }}
Expand Down Expand Up @@ -79,8 +80,9 @@ func main() {
State: "NY",
Zip: "11765",
},
CheckBox: true,
CheckBox2: false,
InputTypes: form.InputFieldTypeEmail,
CheckBox: true,
CheckBox2: false,
},
Errors: []form.FieldError{
fieldError{
Expand Down
2 changes: 0 additions & 2 deletions fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ func (i InputFieldType) Enum() []any {
}

type FieldValue struct {
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Group string `json:"group,omitempty"`
}

type FormField struct {
Expand Down
2 changes: 1 addition & 1 deletion transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (t *Transformer) scanModel(rValue reflect.Value, rType reflect.Type, names
var fieldValue []FieldValue
for _, v := range enums {
fieldValue = append(fieldValue, FieldValue{
Id: fmt.Sprint(v),
Value: fmt.Sprint(v),
Name: fmt.Sprint(v),
Disabled: false,
})
Expand Down

0 comments on commit be342f6

Please sign in to comment.