File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,9 @@ schema =
153
153
, ( " color"
154
154
, buildSchema
155
155
|> withTitle " Color"
156
- |> withDescription " Please enter either red, gren or blue."
156
+ |> withExamples
157
+ [ string " Please enter either red, gren or blue."
158
+ ]
157
159
|> withNullableType " string"
158
160
|> withEnum
159
161
[ string " red"
Original file line number Diff line number Diff line change @@ -127,17 +127,32 @@ fieldView options path schema type_ form =
127
127
128
128
txt : Options -> SubSchema -> F .FieldState ValidationError String -> Html F .Msg
129
129
txt options schema f =
130
- field options
131
- schema
132
- f
133
- [ fieldTitle schema
134
- , Input . textInput f
130
+ let
131
+ attributes =
135
132
[ classList
136
133
[ ( " form-control" , True )
137
134
, ( " is-invalid" , f. liveError /= Nothing )
138
135
]
139
136
, id f. path
140
137
]
138
+
139
+ placeholders =
140
+ case schema. examples of
141
+ Just examples ->
142
+ examples
143
+ |> List . map ( Json . Decode . decodeValue Json . Decode . string)
144
+ |> List . map Result . toMaybe
145
+ |> List . filterMap identity
146
+ |> List . map placeholder
147
+
148
+ Nothing ->
149
+ []
150
+ in
151
+ field options
152
+ schema
153
+ f
154
+ [ fieldTitle schema
155
+ , Input . textInput f ( attributes ++ placeholders)
141
156
]
142
157
143
158
You can’t perform that action at this time.
0 commit comments