So we have our handlers set up, we have a form tag around our entire calendar and we have the route
set up and there's a few other things we need to do before we can actually work with things.
Remember what we want to do here, and this is all we're working on right now is if I uncheck this date
and click save changes, I want to come back to this page whatever month and year I'm currently looking
at.
And I want that block to be removed.
But if I click say this one, which was not checked to start with and click save changes, then I want
to come back to the current page I'm looking at and have this checked.
So what I should be able to check and uncheck things in the same step.
So the first thing to bear in mind is I need to be able to come back to whatever month I'm looking at.
Right now, as I recall, this is December 2020.
Christmas is just a few days away.
But what if I'm looking at this month and I want to block these two dates and click save changes?
I don't want to go back to December 2020, which is the current month.
I want to come back to the one that I was last looking at.
So there's a few changes I need to make.
So I'm going to go back to my I.D. I'm going to find my reservations calendar.
And at the top here in the after this input type equals hidden for CSF token, I'm going to duplicate
that twice and I'm going to call the first one I created M for month and the next one why for a year.
And the value that I'm going to display in there is actually the current month and the current year.
And I already have those in the string maps so I can pull those right out of their index dot string
map.
And the value that I'm looking for is this month.
And this one is going to be also from the index dot string map.
And if you recall, I called that one this month.
Year.
OK, so let's save that reload this page.
I'll just reload this one.
And if I look at this and come down to the search for the word hidden there, they're zero three and
twenty twenty one.
Perfect.
That's what I need.
So I'm definitely going to want to have that.
The other thing to bear in mind, if we scroll down here to this input where I'm displaying the checkbox,
if there is a block in place, I'm checking it.
I give it a name and I give it a value.
But if there's none, if there is no value in index, in the map blocks that I'm just giving it a name,
I actually need to give it a value, too.
Otherwise it's not actually going to get past it.
It won't actually get submitted to the form with any meaningful value.
I'm just going to give it one.
Anything greater than zero will suffice.
So I've made that change.
Now let's go back to our handlers and start thinking about what we're going to do.
Well, the very first thing that I'm doing is I'm posting a form here, so I'll do what I always do
when I when I post a form is I'll pass the form.
Otherwise I can't even write tests for this.
So I'll pass the form.
If error is not equal to nil are standard error check.
And because I'm in the admin here, all I really care about is helper server error w and error and the
return.
OK, which needs to be spelled correctly.
So I've passed my form data.
Now I can actually do something with it.
So those two hidden fields I just added Y and M I'm going to grab those so I can do my redirect appropriately,
appropriately year and I'm going to ignore the error because it's a hidden field that I know is there
is stewart-cousins a2 I and I'm getting asked form douget and this is the year so I and in the one y
and then we'll do month, month and M and now let's do our redirect.
The last thing I do after all of my processing takes place and I'm skipping that step right now is to
redirect.
So I'll just put a message in the session AMD app session put and our context as always, Flash and
I'll lie to us right now.
Changes saved and it's alive because we haven't actually saved the changes yet.
And then we'll do an EDP redirect.
Which requires a response writer appointed to request the Yucel, which will in this case not just be
the name of the calendar page.
I want to take them back to the correct.
You are out.
So we'll use a format as print F format that s print F, and we're going to take them to admin's reservations
calendar and we're going to put Y equals with a with a placeholder for Int and M equals and a placeholder
for an int and the placeholders will be year and month and we need to give them some status http status
c other.
OK, so let's just make sure this works before we go any further so we'll stop this started up again.
And go back to our calendar and I'll click on this one and I'll go to say February twenty twenty one
and I'll just click save changes.
I'll actually check this.
It won't do anything with it, but I'll check it and see safe changes.
And it took me back to February twenty twenty one and it lied to me and said changes are saved.
So that part is working.
The next step is to actually handle the posted blocks and unlocks things that are checked that weren't
before and things that are, that are not checked that were before.
So we actually need to handle that logic in our code right about here.
So this is where we're going to process Bloks.
And we'll get started with that in the next lecture.