Skip to content

Commit 217faf8

Browse files
Zelenyamilesfrain
authored andcommitted
[Chapter 8, 10] Polish the form field
1 parent 83d8de5 commit 217faf8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

exercises/chapter10/src/Main.purs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,26 @@ renderValidationErrors xs =
4646
-- event handler to update
4747
formField :: String -> String -> String -> (String -> Effect Unit) -> R.JSX
4848
formField name placeholder value setValue =
49-
D.label
49+
D.div
5050
{ className: "form-group row"
5151
, children:
52-
[ D.div
52+
[ D.label
5353
{ className: "col-sm col-form-label"
54+
, htmlFor: name
5455
, children: [ D.text name ]
5556
}
5657
, D.div
5758
{ className: "col-sm"
5859
, children:
5960
[ D.input
6061
{ className: "form-control"
62+
, id: name
6163
, placeholder
6264
, value
6365
, onChange:
6466
let
6567
handleValue :: Maybe String -> Effect Unit
6668
handleValue (Just v) = setValue v
67-
6869
handleValue Nothing = pure unit
6970
in
7071
handler targetValue handleValue

exercises/chapter8/src/Main.purs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,20 @@ renderValidationErrors xs =
4444
-- ANCHOR: formField
4545
formField :: String -> String -> String -> (String -> Effect Unit) -> R.JSX
4646
formField name placeholder value setValue =
47-
D.label
47+
D.div
4848
{ className: "form-group row"
4949
, children:
50-
[ D.div
50+
[ D.label
5151
{ className: "col-sm col-form-label"
52+
, htmlFor: name
5253
, children: [ D.text name ]
5354
}
5455
, D.div
5556
{ className: "col-sm"
5657
, children:
5758
[ D.input
5859
{ className: "form-control"
60+
, id: name
5961
, placeholder
6062
, value
6163
, onChange:

0 commit comments

Comments
 (0)