9
9
< div class ="row ">
10
10
< div class ="col-md-6 col-md-offset-3 ">
11
11
< form th:object ="${recipe} " th:action ="@{/recipe} " method ="post ">
12
+ < div th:if ="${#fields.hasErrors('*')} " class ="alert alert-danger ">
13
+ < p > Please correct errors below</ p >
14
+ </ div >
12
15
< input type ="hidden " th:field ="*{id} "/>
13
16
< div class ="pannel-group ">
14
17
< div class ="panel panel-primary ">
@@ -17,17 +20,23 @@ <h1 class="panel-title">Edit Recipe Information</h1>
17
20
</ div >
18
21
< div class ="panel-body ">
19
22
< div class ="row ">
20
- < div class ="col-md-6 form-group ">
23
+ < div class ="col-md-6 form-group " th:class ="${#fields.hasErrors('description')}
24
+ ? 'col-md-3 form-group has-error' : 'col-md-3 form-group' ">
21
25
< label > Recipe Description:</ label >
22
- < input type ="text " class ="form-control " th:field ="${recipe.description} "/>
26
+ < input type ="text " class ="form-control " th:field ="${recipe.description} "
27
+ th:errorclass ="has-error "/>
28
+ < span class ="help-block " th:if ="${#fields.hasErrors('description')} ">
29
+ < ul >
30
+ < li th:each ="err : ${#fields.errors('description')} " th:text ="${err} "/>
31
+ </ ul >
32
+ </ span >
23
33
</ div >
24
34
</ div >
25
35
< div class ="row ">
26
36
< div class ="col-md-2 form-group ">
27
37
< label > Categories:</ label >
28
38
</ div >
29
39
< div class ="col-md-9 form-group ">
30
- <!--todo-->
31
40
< div class ="radio " th:each ="category : ${categories} ">
32
41
< label >
33
42
< input type ="checkbox " value ="" th:text ="${' ' + category.description} "/>
@@ -36,13 +45,27 @@ <h1 class="panel-title">Edit Recipe Information</h1>
36
45
</ div >
37
46
</ div >
38
47
< div class ="row ">
39
- < div class ="col-md-3 form-group ">
48
+ < div class ="col-md-3 form-group " th:class ="${#fields.hasErrors('prepTime')}
49
+ ? 'col-md-3 form-group has-error' : 'col-md-3 form-group' ">
40
50
< label > Prep Time:</ label >
41
- < input type ="text " class ="form-control " th:field ="${recipe.prepTime} "/>
51
+ < input type ="text " class ="form-control " th:field ="${recipe.prepTime} "
52
+ th:errorclass ="has-error "/>
53
+ < span class ="help-block " th:if ="${#fields.hasErrors('prepTime')} ">
54
+ < ul >
55
+ < li th:each ="err : ${#fields.errors('prepTime')} " th:text ="${err} "/>
56
+ </ ul >
57
+ </ span >
42
58
</ div >
43
- < div class ="col-md-3 form-group ">
59
+ < div class ="col-md-3 form-group " th:class ="${#fields.hasErrors('cookTime')}
60
+ ? 'col-md-3 form-group has-error' : 'col-md-3 form-group' ">
44
61
< label > Cooktime:</ label >
45
- < input type ="text " class ="form-control " th:field ="*{cookTime} "/>
62
+ < input type ="text " class ="form-control " th:field ="*{cookTime} "
63
+ th:errorclass ="has-error "/>
64
+ < span class ="help-block " th:if ="${#fields.hasErrors('cookTime')} ">
65
+ < ul >
66
+ < li th:each ="err : ${#fields.errors('cookTime')} " th:text ="${err} "/>
67
+ </ ul >
68
+ </ span >
46
69
</ div >
47
70
< div class ="col-md-3 form-group ">
48
71
< label > Difficulty:</ label >
@@ -57,17 +80,31 @@ <h1 class="panel-title">Edit Recipe Information</h1>
57
80
</ div >
58
81
</ div >
59
82
< div class ="row ">
60
- < div class ="col-md-3 form-group ">
83
+ < div class ="col-md-3 form-group " th:class ="${#fields.hasErrors('servings')}
84
+ ? 'col-md-3 form-group has-error' : 'col-md-3 form-group' ">
61
85
< label > Servings:</ label >
62
- < input type ="text " class ="form-control " th:field ="*{servings} "/>
86
+ < input type ="text " class ="form-control " th:field ="*{servings} "
87
+ th:errorclass ="has-error "/>
88
+ < span class ="help-block " th:if ="${#fields.hasErrors('servings')} ">
89
+ < ul >
90
+ < li th:each ="err : ${#fields.errors('servings')} " th:text ="${err} "/>
91
+ </ ul >
92
+ </ span >
63
93
</ div >
64
94
< div class ="col-md-3 form-group ">
65
95
< label > Source:</ label >
66
96
< input type ="text " class ="form-control " th:field ="*{source} "/>
67
97
</ div >
68
- < div class ="col-md-3 form-group ">
98
+ < div class ="col-md-3 form-group " th:class ="${#fields.hasErrors('url')}
99
+ ? 'col-md-3 form-group has-error' : 'col-md-3 form-group' ">
69
100
< label > URL:</ label >
70
- < input type ="text " class ="form-control " th:field ="*{url} "/>
101
+ < input type ="text " class ="form-control " th:field ="*{url} "
102
+ th:errorclass ="has-error "/>
103
+ < span class ="help-block " th:if ="${#fields.hasErrors('url')} ">
104
+ < ul >
105
+ < li th:each ="err : ${#fields.errors('url')} " th:text ="${err} "/>
106
+ </ ul >
107
+ </ span >
71
108
</ div >
72
109
</ div >
73
110
</ div >
@@ -103,8 +140,16 @@ <h1 class="panel-title">Directions</h1>
103
140
</ div >
104
141
< div class ="panel-body ">
105
142
< div class ="row ">
106
- < div class ="col-md-12 form-group ">
107
- < textarea class ="form-control " rows ="3 " th:field ="*{directions} "> </ textarea > </ div >
143
+ < div class ="col-md-12 form-group " th:class ="${#fields.hasErrors('directions')}
144
+ ? 'col-md-12 form-group has-error' : 'col-md-12 form-group' ">
145
+ < textarea class ="form-control " rows ="3 " th:field ="*{directions} "
146
+ th:errorclass ="has-error "> </ textarea >
147
+ < span class ="help-block " th:if ="${#fields.hasErrors('directions')} ">
148
+ < ul >
149
+ < li th:each ="err : ${#fields.errors('directions')} " th:text ="${err} "/>
150
+ </ ul >
151
+ </ span >
152
+ </ div >
108
153
</ div >
109
154
</ div >
110
155
</ div >
0 commit comments