Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Applied web development
Lecture: Concept: Anatomy of an HTML form

Login or purchase this course to watch this video and the rest of the course contents.
0:03 Everything we've done so far has been data that the users can consume,
0:06 but they haven't been able to contribute or edit it in even the simplest way.
0:11 We are going to address that now in the next couple of lectures.
0:13 So let's start by talking about HTML forms
0:16 specifically within the context of Chameleon templates, but also in general.
0:20 Here is a form and this is a very simple form,
0:23 what it lets users do is enter their email address and their password
0:26 and then log into our website. In our website we are just going to say
0:29 the email address is the username, keep it simple.
0:32 So you can see, everything is contained within a form and forms have actions
0:36 and they have methods, so here the action is just double quote
0:39 which means it's going to submit back to the same page, that rendered this form,
0:44 so if the page that rendered it was /accounts/signin,
0:49 it's going to post back, to that exact same URL, and this is usually what you want.
0:54 It also has a method the method is POST, it could be GET,
0:58 it could be some other thing that might limit us in a few ways,
1:00 typically POST is important, POST communicates to the server
1:04 that you don't want to be able to cache this,
1:06 you are possibly altering data, things like that.
1:09 It has a number of input forms, as well as a single button,
1:13 and these input forms have a type so like text and password,
1:17 and they optionally have a value,
1:19 here we are specifying a value of ${email_address} and ${password}
1:24 Initially, you can imagine those would be empty.
1:27 But it could be that they submitted this form back to us
1:30 and they had typed in an email address
1:32 and there are some kind of reason they couldn't log in,
1:34 but we'd like to preserve that data that they have submitted to us for multiple round trips.
1:39 So we can do that by refilling,
1:41 repopulating the input fields with whatever data they had entered.