 Hey everybody, this is Brian and welcome to the eighth tutorial. This one's on views and this is actually what we're going to be spending the bulk of our time dealing with the eFramework because, well, the bulk of what you see is, well, views. So, I think I goofed a little bit at the end and I said it was about controllers and it was actually about models and controllers, so forgive me there, but so what is the view? Well, as I've been flipping through here, we've been seeing views. So let's actually go to the teachers and you see how we've got multiple records in here. If you haven't already created a couple, just go ahead and create a couple in here and this is the index view and I'm just going to click on one and you see how it's the same information just presented differently. That's a view. A view can take any information and display it in just about any fashion. For example, if I go manage, whoops, I need to log in there. This is also a view, even though we have this searchable grid here, whoops, can't even spell Bob, that's pretty bad. You know, we've got this searchable grid, but it's still a view. So let's take a look at views and if you're wondering how to get, don't go to protected and views and let's expand teachers and you see how we've got a lot of these and we've kind of touched on these a little bit here, but we're going to really look at these. Core form, underscore search, underscore view, admin create index update view. So index, this is the first page that we see here. It's actually list teachers. This is the index page. You see how it's got this little cell for each one and we're just playing one of two records and you can click on it. That's how that's rendered and this is what it looks like. This is a standard view. We're listing the data provider and the controller. We're listing the breadcrumb. If you're wondering what a breadcrumb is, it's this little strip across the top here. So if we click on this, you see how it's home teachers and this. So we can just click on teachers and bang, we're right back where we were. And then we have this menu here and this menu is different for every page. We can see how we've create and manage. So when we're on the index page, we have create and admin, create admin. That just routes us to the different pages or the different views. So we can click create. Notice how the list changes. Click manage. You can edit one of these. You notice how we get a lot more. That's the menu right there. And then we just have our page and we've got our header here and then we are doing seeing a Z widgets C list view to view that. And the data provider is actually just the model. See how it says C active data provider. So that's a lot to take in. Let's actually look at this on the controller and see what we're doing here. That's why you really need to understand all this because it's all really integrated. So when we look at this, we're doing a data provider equal new C active data provider teachers. Essentially what we're doing is we're saying get the teachers model and call the search function in there. And if you remember, it's actually good models. Search is just basically saying search for everything and return everything. So we're essentially returning array of all of the teachers in there. And we could define special search parameters if we want to. But for this tutorial, we're going to keep it simple. So we get our search and now we're going to render the view in this case index. And we're saying data provider equal data provider and the actual variable name. That's how we're passing that through. Let's take another example. Let's go to create. We get this nice form here. Once again, we have our breadcrumbs. We have our menu. We've got our little header here. And then we're saying this render partial underscore form and we're passing a model to it. So this render partial, what does that mean? Well, we're taking this file, this underscore form and rendering it right here where this line is. But at the same time, we're also taking a variable called model and passing it as a variable name model. Sounds confusing. Let's look at this guy. So this is the actual form that we're rendering. The reason why this is broken off into separate files is because we'll actually use this several times through several other files. So rather than copy and paste the information in the same file, it's much more efficient to have it in an external file and do a render partial. And as you can see, this is just the form that we're rendering. We've got our error summary. We've got a first name and a last name. Now in each one of these, we're doing a label, the field, and the error. If there is one. That would be like if it's a required field, it would print out the error. And then there's our submit button. We're saying model if it is a new record, yes, create, no, save. It's going to be the text of that. Seems pretty difficult, but it's pretty easy to understand. You just type in like, um, John Doe, and you create. Okay, let's take another example here. And let's look at something a little more complex. Let's look at update. Now when you look at update, you'll see that it's pretty much similar. We've got our declarations, we've got our breadcrumb, we've got our menu. And then of course it's once again loading that underscore form. Same thing that creates doing. Same form, just using it differently. So let's actually look at the controller for this. Notice how this is a little bit different. We've got update and then we've got a parameter of ID. Let's follow along here. Let's go list teachers and let's just pick Mary Jane here and we're going to go update. Now you notice how when you click that in the query string, it says ID equals seven. Controllers teachers, the view is update, ampersand means we got a parameter, the parameters ID equals seven. So essentially what we're doing is saying teacher controller, load the update view with record seven. Let's go out here and look at this thing. So we're passing the ID, which is in this case seven, say model, load model, and then of course that's going to be seven. So we're loading the seven and then we're saying if we're posting back, whenever you see if is set post, think we're posting back, meaning somebody's clicked a button. If we're saving it more or less, we're going to load the attributes of that post or that form called teachers, which is defined in this underscore forms. Let's see if I can find it here. I'm usually very bad at this. Yes. ID equals teachers form. So that's where we're loading that. And we're rendering it there. Just really want you to understand that. Oops. Get back here. And then we save the model and then we redirect them to the view. If we're not posting back, we're just rendering the update or rendering the page with the model. Whew. Sounds like a mouthful. Let's walk through this. So we're just here. We haven't clicked this button yet. So what are we looking at? Let's jump back in here. We're not looking at this because it's not a post back. So we're looking at this render update. So they're taking the update page and they're rendering the model. As you can see, it just loads the information. And then we're rendering partial form and we're passing the model to it. So we'll take that form. And this is where we're saying, for example, this row label extended, and we're displaying the model parameter first name, the text field model parameter first name. Same thing with the last name. And you can see how this is very easy to understand. It just flows. Even without walking into this tutorial more than an hour of video information, you can actually look at this and see what you're actually loading up. It's pretty easy to get. So when we go in here and say we want to call her Mary Jones, hit save, we know what happened at this point. We've saved the information. So we've effectively read the post back and we've read the attributes into the model and then we've saved the model and then we've redirected to the view. The rest of these are pretty much self-explanatory. Admin may be a little complicated. We will discuss this in future tutorials in depth, but it's pretty much the same concept. You're just loading the models and then displaying them in a secret view, which has a few buttons. If you're wondering what that looks like, click manage and then there it is. Voila! Well, I hear thunder and lightning, so I'm going to cut this tutorial a little bit short. We're going to really deep dive into a lot of this in future tutorials, so stay tuned.