1
00:00:00,540 --> 00:00:05,910
So we're going to do some server side form validation, and you might be asking yourself why?

2
00:00:06,030 --> 00:00:08,370
I mean, look at this, make a reservation form.

3
00:00:08,400 --> 00:00:12,950
If I try to fill it out and there's an error, it displays an error right there.

4
00:00:12,960 --> 00:00:18,260
So we have client side validation and that's handled by our bootstrap client side validation.

5
00:00:18,270 --> 00:00:19,110
And it works well.

6
00:00:19,120 --> 00:00:19,860
It really does.

7
00:00:20,850 --> 00:00:22,680
But you never want to trust user input.

8
00:00:22,830 --> 00:00:27,950
Any time a user has an opportunity to enter something on a form, you can't make any assumptions.

9
00:00:27,990 --> 00:00:32,280
So, for example, when I try to fill this form out, great, it works great.

10
00:00:32,280 --> 00:00:34,350
If I put a first name in here that turns green.

11
00:00:34,350 --> 00:00:41,070
But the problem is that is what we call client side validation, and that is implemented in almost every

12
00:00:41,070 --> 00:00:41,460
case.

13
00:00:41,460 --> 00:00:42,840
I actually can't think of another case.

14
00:00:42,840 --> 00:00:49,200
Client side validation is handled using JavaScript and it is possible that a user might hit this form

15
00:00:49,230 --> 00:00:50,930
with JavaScript turned off.

16
00:00:51,660 --> 00:00:55,890
Now, they're not going to see a lot of things and like this drop down menu wouldn't work, but it's

17
00:00:55,890 --> 00:00:57,000
possible they can get here.

18
00:00:57,000 --> 00:00:59,240
And you have to assume the worst case scenario.

19
00:00:59,670 --> 00:01:04,590
So what if someone hits this page and has JavaScript turned off in their browser, it's possible for

20
00:01:04,590 --> 00:01:08,520
them to submit the form without all four required fields.

21
00:01:08,880 --> 00:01:12,000
And another thing to bear in mind is that here, if I type in.

22
00:01:12,150 --> 00:01:14,400
Yes, that's an email address.

23
00:01:14,790 --> 00:01:17,410
That's not an email address that is seen as an email address.

24
00:01:17,430 --> 00:01:19,680
Well, that's actually not a valid email address.

25
00:01:19,680 --> 00:01:24,200
There is no such thing on the clear public Internet as an address in this format.

26
00:01:24,210 --> 00:01:27,720
There might be on an internal network, but there's not on the outside world.

27
00:01:27,930 --> 00:01:31,110
And our Web page is going to be served to the outside world.

28
00:01:31,470 --> 00:01:36,840
So we definitely want to implement clients are server side form validation and we're going to do it

29
00:01:37,050 --> 00:01:38,120
on this form.

30
00:01:38,610 --> 00:01:43,500
So in order to do that, we need to make a few changes to our code, a few additions to our code, really.

31
00:01:43,800 --> 00:01:48,410
So the very first thing I'm going to do is I want to create a new internal package.

32
00:01:48,450 --> 00:01:52,380
So over in the internal folder, I'm going to create a new directory.

33
00:01:53,100 --> 00:01:56,910
So new directory, which I will call forms.

34
00:01:57,760 --> 00:01:59,280
So this is an internal package.

35
00:01:59,640 --> 00:02:05,820
Inside of that, I'm going to, first of all, create three files, create one called Errors Dutko or

36
00:02:05,820 --> 00:02:06,660
two files for now.

37
00:02:07,290 --> 00:02:08,640
And I'm not going to to get you.

38
00:02:09,330 --> 00:02:13,200
And then I'll create another one called Form Dongo.

39
00:02:14,130 --> 00:02:15,360
So I've created these files.

40
00:02:15,930 --> 00:02:18,710
And if I look at the list of the errors one first.

41
00:02:19,560 --> 00:02:24,000
So what I'm going to do in the Errors package, which is right here, are the errors file in the forms

42
00:02:24,000 --> 00:02:27,060
package is I'm going to create a type and I'm going to create a type.

43
00:02:27,060 --> 00:02:27,900
You know what a type is.

44
00:02:27,900 --> 00:02:28,860
We've done it many times.

45
00:02:28,860 --> 00:02:29,940
We usually use a struct.

46
00:02:29,940 --> 00:02:32,340
But in this case, I'm going to create a type with the name of errors.

47
00:02:33,000 --> 00:02:34,710
So that's my name for this type.

48
00:02:35,010 --> 00:02:38,940
And it's going to be a type of map, string, string.

49
00:02:39,780 --> 00:02:44,130
So I've declared a package level variable that's not exported called errors.

50
00:02:44,130 --> 00:02:49,600
And it's going to hold a map with an index of string and area value in that map will also be a string.

51
00:02:50,610 --> 00:02:55,110
Now I'm going to create a new function and I'm going to call a function called ADD and this will be

52
00:02:55,110 --> 00:02:58,500
used so func and I'll call it E errors.

53
00:02:58,500 --> 00:03:00,800
So I'll tie it to that errors variable that we have.

54
00:03:00,810 --> 00:03:02,250
So it has a receiver for that.

55
00:03:02,250 --> 00:03:04,590
So now it has access to anything in that errors.

56
00:03:05,310 --> 00:03:09,060
And I'm going to call this at and it's only going to add an error.

57
00:03:09,060 --> 00:03:13,860
It gives us a means to say, hey, there's an error in our data that we receive from the form.

58
00:03:14,160 --> 00:03:20,760
Please add this to the errors so we can do that pretty easily and we can do it by saying, well, what

59
00:03:20,760 --> 00:03:22,380
field is the error in now?

60
00:03:22,380 --> 00:03:22,920
A field?

61
00:03:22,960 --> 00:03:29,940
Let's just bring up that we hide this and bring up under our templates that make reservation page.

62
00:03:30,570 --> 00:03:32,190
So here we have four fields.

63
00:03:32,190 --> 00:03:35,010
We have one called First Name with an idea.

64
00:03:35,010 --> 00:03:35,490
First name.

65
00:03:35,490 --> 00:03:36,480
It's called first name.

66
00:03:36,480 --> 00:03:38,430
We have first name, last name, email and phone.

67
00:03:38,610 --> 00:03:39,060
Perfect.

68
00:03:39,240 --> 00:03:40,500
So that's what I mean by field.

69
00:03:41,100 --> 00:03:45,600
So it's going to be a field and there's going to be a message associated with the error, which can

70
00:03:45,600 --> 00:03:46,470
be whatever we want.

71
00:03:46,470 --> 00:03:49,320
And these are both going to be strings and this doesn't return anything.

72
00:03:49,440 --> 00:03:51,270
This is just a function that adds something.

73
00:03:51,720 --> 00:03:59,580
So to our variable e from our receiver, we want to in the index field, which doesn't exist yet, but

74
00:03:59,580 --> 00:04:00,360
don't worry about that.

75
00:04:00,690 --> 00:04:06,690
We want to append E field and a message.

76
00:04:08,190 --> 00:04:11,190
So when you look at it, I have a mistake up here.

77
00:04:11,190 --> 00:04:13,590
There should be a slice of strings, not a string.

78
00:04:14,310 --> 00:04:18,630
So our errors is a map of string with a contents being a slice of strings.

79
00:04:18,810 --> 00:04:22,920
So we are appending our error to that particular slice.

80
00:04:23,430 --> 00:04:28,170
And what we're putting in there is an error for a given field like first name and some kind of message.

81
00:04:28,290 --> 00:04:32,970
Maybe its first name must be at least three characters or something like that.

82
00:04:32,970 --> 00:04:33,570
It doesn't matter.

83
00:04:33,810 --> 00:04:35,550
That's all that that function does.

84
00:04:35,820 --> 00:04:37,890
And we're going to create one more function here.

85
00:04:37,920 --> 00:04:42,810
OK, func also with the receiver on errors and it's going to be called GET.

86
00:04:44,070 --> 00:04:45,660
And this is where we can get information.

87
00:04:46,230 --> 00:04:50,580
So it takes one parameter field string and it returns a string.

88
00:04:51,930 --> 00:04:55,740
And what we're going to do here is create an error string, just a variable, and that's going to be

89
00:04:55,740 --> 00:04:59,910
assigned the value of whatever we find in our map with the index of the.

90
00:05:03,390 --> 00:05:09,760
And if the length of X is equal to zero, then we want to do something.

91
00:05:09,870 --> 00:05:10,960
What do we want to do?

92
00:05:12,090 --> 00:05:14,790
We want to return nothing.

93
00:05:15,000 --> 00:05:16,120
So there's no error for that.

94
00:05:16,170 --> 00:05:19,350
This is all this is checking return an empty string.

95
00:05:20,430 --> 00:05:23,450
But if it doesn't pass that I got a mistake here somewhere.

96
00:05:25,500 --> 00:05:30,450
Don't there there are, but if it doesn't get returned at this point, then what do we do?

97
00:05:30,500 --> 00:05:37,180
We return, yes, our error, string zero, the first index on the airstrip.

98
00:05:37,220 --> 00:05:40,220
So this is a means of seeing whether or not a given field has an air.

99
00:05:40,220 --> 00:05:41,220
And that's all that this does.

100
00:05:41,240 --> 00:05:47,690
So let's give these things some comments, get what is get to it implements and get method.

101
00:05:47,750 --> 00:05:55,610
It returns or retrieves the first error message returns the first error message.

102
00:05:55,670 --> 00:05:57,890
And this will become clearer when we actually use these functions.

103
00:05:57,890 --> 00:06:03,980
But this is not that common, complicated and add well, it adds an error message for a given field

104
00:06:04,570 --> 00:06:09,510
and an error message for a given form field.

105
00:06:09,680 --> 00:06:10,950
So that's all those functions do.

106
00:06:11,120 --> 00:06:11,450
All right.

107
00:06:11,460 --> 00:06:17,240
So we've got those functions created now over in our forms, package forms, page in our forms package.

108
00:06:17,240 --> 00:06:18,380
This forms Dargo.

109
00:06:18,800 --> 00:06:20,380
We need to put some things in here as well.

110
00:06:20,390 --> 00:06:22,290
The first thing we need to do is to define a type.

111
00:06:22,490 --> 00:06:27,530
This is what we're going to use to hold our form, all of the information associated with our form,

112
00:06:28,220 --> 00:06:34,760
either when it's rendered for the very first time and the struct is actually empty or after the form

113
00:06:34,760 --> 00:06:37,370
is submitted, when there may be one or more errors in there.

114
00:06:37,430 --> 00:06:44,660
And we'll just call this form and it's going to be a struct and it will hold your URL values, which

115
00:06:44,660 --> 00:06:46,570
comes from the net neutrality package.

116
00:06:46,640 --> 00:06:54,470
OK, so it holds some values from the form and it holds errors, which is of type errors which we just

117
00:06:54,470 --> 00:06:54,890
created.

118
00:06:55,220 --> 00:07:01,010
OK, so that's an R struct is our type is and that's going to hold all of our form information.

119
00:07:01,190 --> 00:07:06,320
And we also need to put a method here, a function here called New to create a new form.

120
00:07:06,770 --> 00:07:12,740
And it's going to have a parameter of data which consists of Eurail values, which is built into the

121
00:07:12,740 --> 00:07:18,270
gold standard library, and it returns a type of a pointer to a form.

122
00:07:18,830 --> 00:07:21,130
So we're going to create a new form with a pointer to it.

123
00:07:21,140 --> 00:07:24,410
And because it's a pointer, we can access it from anywhere using that pointer.

124
00:07:24,410 --> 00:07:25,930
And no, we're pointing at the right form.

125
00:07:26,420 --> 00:07:30,680
So all we have to do here is return something, returning a form, and since it's new, it's going to

126
00:07:30,680 --> 00:07:31,160
be empty.

127
00:07:31,580 --> 00:07:37,840
So we will say return a pointer to a form type, which we just defined up here.

128
00:07:38,300 --> 00:07:43,270
And in that we're going to have data which is, you know, nothing right now that's just from this parameter.

129
00:07:43,280 --> 00:07:51,680
So our data right there and it's going to have an errors type, which consists of a map of string and

130
00:07:51,680 --> 00:07:52,550
a slice of strings.

131
00:07:54,220 --> 00:07:56,780
No less so now we have a new function.

132
00:07:56,800 --> 00:07:57,590
So what does that do?

133
00:07:57,610 --> 00:08:03,450
Well, let's give it a comment so we won't forget new initializes the form structure.

134
00:08:09,040 --> 00:08:13,450
So when it's initialized, it doesn't have any values in here at all except for the data that we passed

135
00:08:13,450 --> 00:08:13,560
it.

136
00:08:13,570 --> 00:08:17,980
And that was those would be corresponding to the inputs on our form field.

137
00:08:18,310 --> 00:08:22,540
And we may as well give form our type a comment as well.

138
00:08:22,570 --> 00:08:23,920
You're supposed to say, let's do that.

139
00:08:24,280 --> 00:08:25,030
So it is formed.

140
00:08:25,100 --> 00:08:35,680
Well, it creates a custom form struct and it embeds a neutral values object.

141
00:08:36,400 --> 00:08:36,910
That's enough.

142
00:08:37,180 --> 00:08:40,750
OK, so now we have our new function.

143
00:08:41,230 --> 00:08:45,550
We have our type that is going to hold our form values.

144
00:08:45,760 --> 00:08:49,960
And under airs we have a function to add an error and a function to get an error.

145
00:08:50,210 --> 00:08:52,020
OK, so there's an error here somewhere.

146
00:08:52,840 --> 00:08:54,070
Map, string, string.

147
00:08:55,040 --> 00:08:55,480
Oh yeah.

148
00:08:56,020 --> 00:08:59,650
I can't just put string like that because I'm declaring it to be empty, so I have to put the pretty

149
00:08:59,650 --> 00:09:00,550
curly brackets there.

150
00:09:00,640 --> 00:09:00,980
All right.

151
00:09:01,990 --> 00:09:03,280
So this is great.

152
00:09:03,620 --> 00:09:10,210
And what we're going to do in the forms go file is we're actually going to define certain checks to

153
00:09:10,210 --> 00:09:13,300
see if the form data we received is valid.

154
00:09:13,300 --> 00:09:14,380
So let's do one right now.

155
00:09:14,470 --> 00:09:16,200
We're not using it yet, but let's do it.

156
00:09:16,210 --> 00:09:21,160
And that's one of the things you definitely want to have when you're checking data server side, you're

157
00:09:21,160 --> 00:09:26,600
validating data that the users have entered into a form and you want to make sure that the data is actually

158
00:09:26,630 --> 00:09:28,000
same before you do anything.

159
00:09:28,030 --> 00:09:34,210
Well, the very first thing I would have is let's make sure and we'll create a function with a receiver

160
00:09:34,210 --> 00:09:41,730
of type form, pointer to form and we'll call it has a required field.

161
00:09:41,830 --> 00:09:45,000
So you need to say, well, what actually is included?

162
00:09:45,010 --> 00:09:46,150
What is the field that's required?

163
00:09:46,160 --> 00:09:48,660
So that's going to be named field and that's a string.

164
00:09:48,970 --> 00:09:52,240
So for first name on our form over wherever it is.

165
00:09:53,290 --> 00:09:58,180
This page, for example, if this is a required field, well, the field I'm going to pass, it is the

166
00:09:58,180 --> 00:10:00,700
name of the field in the form, which is ID.

167
00:10:00,700 --> 00:10:01,530
So let's go back here.

168
00:10:02,440 --> 00:10:08,500
So it's going to take a required parameter, a field that names that parameter that is required and

169
00:10:08,500 --> 00:10:09,780
we're going to check to see if it's in there.

170
00:10:10,300 --> 00:10:15,390
So to do that, we need to have access to the request object, what the browser sends to us.

171
00:10:15,520 --> 00:10:23,170
And that is, as you know from our handlers, always a pointer to type HTTP request and it's going to

172
00:10:23,170 --> 00:10:24,040
return lool.

173
00:10:24,910 --> 00:10:32,830
So when I call this function, I want to say, does the form submitted by the user have a field named

174
00:10:32,920 --> 00:10:34,090
first name, for example?

175
00:10:34,270 --> 00:10:35,440
If it does, I'll return.

176
00:10:35,440 --> 00:10:35,830
True.

177
00:10:35,830 --> 00:10:37,430
If it doesn't, it returns false.

178
00:10:37,720 --> 00:10:39,390
So checking it is really easy.

179
00:10:39,430 --> 00:10:41,860
I can just do it like we did in our handlers.

180
00:10:41,860 --> 00:10:47,410
When we there are kind of stub form handlers, I can create a variable which I'll call X and I'll just

181
00:10:47,410 --> 00:10:49,290
check the request form.

182
00:10:49,480 --> 00:10:50,230
Not yet.

183
00:10:50,590 --> 00:10:55,770
And I'm going to get the field and we just look to see if that field has any data.

184
00:10:55,780 --> 00:10:59,860
If X is equal to nothing, then there's an error return false.

185
00:11:00,910 --> 00:11:04,690
There's not actually an error because it's OK to have an empty form field.

186
00:11:05,020 --> 00:11:09,190
But in our case, we want to make sure this is a required field otherwise return.

187
00:11:09,190 --> 00:11:09,610
True.

188
00:11:09,730 --> 00:11:11,020
And that's all there is to it.

189
00:11:11,170 --> 00:11:18,490
So we've created a custom function, a validator, and we'll give it its comment has and will describe

190
00:11:18,490 --> 00:11:25,780
it as saying checks if form field is in post and not empty.

191
00:11:25,990 --> 00:11:27,490
And that's a requirement for has.

192
00:11:27,580 --> 00:11:28,590
That's all that it does.

193
00:11:29,110 --> 00:11:30,640
So I've created these things.

194
00:11:30,820 --> 00:11:32,420
How do I actually use them?

195
00:11:32,560 --> 00:11:34,960
Well, we need to, first of all, set up a handler.

196
00:11:34,960 --> 00:11:40,360
So let's go over to our roots and find make reservation and duplicate this.

197
00:11:40,750 --> 00:11:45,670
And we'll call this one using my naming convention, because this is a post post reservation, which

198
00:11:45,670 --> 00:11:46,480
doesn't exist yet.

199
00:11:46,480 --> 00:11:47,230
But that's no problem.

200
00:11:47,530 --> 00:11:49,390
We have to change this type to post as well.

201
00:11:49,930 --> 00:11:51,160
So I've got the route set up now.

202
00:11:51,160 --> 00:11:52,300
I have to go create the handler.

203
00:11:52,840 --> 00:11:54,700
So I go over to my handlers file.

204
00:11:55,000 --> 00:11:57,310
I find the reservation part right here.

205
00:11:57,310 --> 00:11:58,090
I'm going to copy this.

206
00:11:58,090 --> 00:12:02,380
And we have to make a change to this one in a moment and we'll paste it and we'll just leave this empty

207
00:12:02,380 --> 00:12:02,800
right now.

208
00:12:04,650 --> 00:12:13,380
And we'll change its name to post reservation and will change its comment to post reservation handle's.

209
00:12:16,160 --> 00:12:19,860
The posting of a reservation form.

210
00:12:22,490 --> 00:12:29,780
OK, now there's one more thing I need to do here, because I want to be able to check the form after

211
00:12:29,780 --> 00:12:33,740
it's submitted, but I need to display the form before it's submitted.

212
00:12:34,010 --> 00:12:36,470
So I need to add something to template data.

213
00:12:36,860 --> 00:12:42,110
And I'm going to do that by going over to my templates day to go file and I'm going to add a column

214
00:12:42,110 --> 00:12:49,040
here or add a member here and I'm going to call it form and it's going to be type of a pointer to form

215
00:12:49,040 --> 00:12:49,820
start form.

216
00:12:50,660 --> 00:12:54,340
OK, so I've added that did the import for me, so it's important properly.

217
00:12:54,710 --> 00:13:00,760
Now there's a new member that I have on my template data, something that's sent to every page.

218
00:13:00,770 --> 00:13:06,190
So whether a page has a form or not, I know that the form object is going to be available to me.

219
00:13:06,830 --> 00:13:08,870
So let's go back to our handlers.

220
00:13:09,260 --> 00:13:17,390
And now when I'm rendering this this reservation right here, I need to give it a form object.

221
00:13:17,540 --> 00:13:19,570
And I can do that because it's part of the template, too.

222
00:13:19,580 --> 00:13:23,420
So it's form and it's going to be equal to forms.

223
00:13:23,600 --> 00:13:27,190
Dot knew that function was created just a little while ago.

224
00:13:27,440 --> 00:13:28,070
I'm going to pass it.

225
00:13:28,070 --> 00:13:29,040
No values at all.

226
00:13:29,390 --> 00:13:35,900
So the very first time that form is rendered on this page, I have access to that forms object.

227
00:13:35,900 --> 00:13:37,310
I'm not doing anything with it yet.

228
00:13:37,310 --> 00:13:41,300
We will probably in the next lecture, but now I know I have access to it.

229
00:13:41,300 --> 00:13:43,820
So that means it's available the first time it's displayed.

230
00:13:44,090 --> 00:13:49,550
And then when I if somebody submits the form and they come back and there are errors, I'm going to

231
00:13:49,550 --> 00:13:51,020
use this function.

232
00:13:51,050 --> 00:13:55,670
The Horsfield, for example, the house function, for example, to say, aha, you needed to have a

233
00:13:55,670 --> 00:14:02,210
first name, but you don't have a first name, therefore render the form, but this time display the

234
00:14:02,210 --> 00:14:02,600
error.

235
00:14:02,840 --> 00:14:08,660
And the great thing about this is I can display the error, but I can also display all of the other

236
00:14:08,660 --> 00:14:12,140
information that the user entered will be able to do that eventually.

237
00:14:12,710 --> 00:14:13,360
That's correct.

238
00:14:13,490 --> 00:14:18,860
So I'm not going to just bounce them back to have them fill out a long form, had them submit it only

239
00:14:18,860 --> 00:14:23,120
to discover after the fact that there's an error, take them back to the page with an error message

240
00:14:23,360 --> 00:14:25,030
and have lost the rest of that information.

241
00:14:25,130 --> 00:14:27,290
There's nothing more frustrating than that.

242
00:14:27,500 --> 00:14:32,360
When you're working on a website and you fill out a form and you get an error message and you've lost

243
00:14:32,360 --> 00:14:33,150
everything you've entered.

244
00:14:33,170 --> 00:14:36,830
Well, we don't want that to happen to our users because we don't want to lose any potential reservations.

245
00:14:37,100 --> 00:14:41,600
So we're going to make sure we display the error, give them some indication as to what the error is

246
00:14:41,600 --> 00:14:45,350
and where it needs to be fixed and save all that other information.

247
00:14:45,740 --> 00:14:48,150
And we'll do that in the not too distant future.

248
00:14:48,210 --> 00:14:50,420
Right now, let's just make sure that everything works.

249
00:14:50,420 --> 00:14:52,610
So I'm going to start my application, which I had running.

250
00:14:53,000 --> 00:14:53,840
I'll compile it.

251
00:14:53,840 --> 00:14:55,760
Go run command Web Stargirl.

252
00:14:57,600 --> 00:15:03,300
It compiled and I should be able to go back to this form and reload the page and there it is and it

253
00:15:03,300 --> 00:15:04,520
works just beautifully.

254
00:15:05,010 --> 00:15:09,560
Now, of course, what one more thing I'll do before we call it a day for this lecture is I need to

255
00:15:09,570 --> 00:15:12,920
turn off this custom of a client side validation.

256
00:15:12,930 --> 00:15:17,190
So let me go back, find that page and turn it off temporarily.

257
00:15:17,190 --> 00:15:21,420
And we can turn it off just by saying get rid of this class needs validation.

258
00:15:21,420 --> 00:15:24,120
So I'll leave class in there and we'll have to remember to turn it back on.

259
00:15:24,540 --> 00:15:29,460
But now when I come back and reload this, this should take me to a level that I actually have an action

260
00:15:29,460 --> 00:15:29,690
in there.

261
00:15:29,700 --> 00:15:29,900
Yeah.

262
00:15:29,910 --> 00:15:32,880
Make reservationist the correct path for the roots.

263
00:15:33,240 --> 00:15:38,880
I should be able to submit this and get an empty screen because our handler that handles it under route's,

264
00:15:38,880 --> 00:15:43,910
wherever they're there, their post reservation doesn't do anything.

265
00:15:43,920 --> 00:15:45,540
It's an empty it's an empty function right now.

266
00:15:45,540 --> 00:15:49,620
So it just it should give me a white screen and it gives me a bad request.

267
00:15:49,620 --> 00:15:50,040
Why?

268
00:15:50,040 --> 00:15:59,310
Because I forgot on my make reservation page to put in my hidden field input type equals hidden name

269
00:15:59,310 --> 00:16:08,790
equals SRF token value equals and in quotes see R.F. Token pulling that out of my template data that

270
00:16:08,880 --> 00:16:09,870
passed to every page.

271
00:16:10,150 --> 00:16:13,620
So it should be able to go back to that page, reload this form.

272
00:16:13,800 --> 00:16:15,210
There should be a hidden field in there.

273
00:16:15,220 --> 00:16:16,560
Now there it is.

274
00:16:16,560 --> 00:16:16,950
Good.

275
00:16:17,070 --> 00:16:20,600
OK, now I can submit an empty form and get a blank page and it does.

276
00:16:20,850 --> 00:16:24,480
So I'm posting, I have created an empty form element.

277
00:16:24,810 --> 00:16:25,920
Let's just go through this again.

278
00:16:26,520 --> 00:16:27,720
We'll start right from the roots.

279
00:16:27,720 --> 00:16:33,510
So somebody comes to the make reservation page and that tells them to go, I'm going to this page,

280
00:16:33,510 --> 00:16:39,480
going to make Dasch reservation, therefore go to the handler called reservation in my handler's package

281
00:16:40,320 --> 00:16:47,370
and reservation says, OK, just render that template, make reservation page tampoe and include an

282
00:16:47,370 --> 00:16:48,210
empty form.

283
00:16:48,540 --> 00:16:50,160
And that's exactly what it does.

284
00:16:50,190 --> 00:16:51,970
What is forms new do?

285
00:16:51,990 --> 00:16:52,800
Well, let's look at that.

286
00:16:53,130 --> 00:16:56,070
All that does it say it's going to have a value of data.

287
00:16:56,070 --> 00:16:57,120
You are values.

288
00:16:57,120 --> 00:16:59,760
So that's some values taken from a form.

289
00:16:59,760 --> 00:17:04,230
And because we're displaying this for the first time, this error, this data package is going to be

290
00:17:04,500 --> 00:17:05,670
and it's going to be empty.

291
00:17:05,670 --> 00:17:06,540
It's going to be nil.

292
00:17:06,900 --> 00:17:08,460
And that's what I'm passing it in.

293
00:17:08,460 --> 00:17:09,510
My handler's right here.

294
00:17:09,510 --> 00:17:10,980
I'm passing it a value of nil.

295
00:17:11,430 --> 00:17:13,980
As for the map, that's absolutely empty.

296
00:17:14,370 --> 00:17:16,680
There's nothing in there right now in terms of errors at least.

297
00:17:16,950 --> 00:17:23,820
So we're good to go now in the next lecture will actually try testing some of our one validator required

298
00:17:23,820 --> 00:17:26,520
fields and we'll pick that up in the next election.
