This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Now our users can create a new Page. But they'd better get it right the first time, because right now they can't go back and change what they've entered... Maybe we should fix that. Let's give them a form to allow them to update existing Pages.
When a user wants to create a new model object, the browser sends an HTTP GET request to retrieve a blank form. When they submit the new form, the browser sends an HTTP POST request to create a new record on the server.
And when a user wants to edit an existing model object, the browser needs to send an HTTP GET request to retrieve that form as well. The difference is that the edit form will be pre-populated with the existing object's data.
Another difference is that when you're modifying existing data on the server (rather than adding new data), you're supposed to use a PUT or PATCH request rather than a POST request. So when you click the submit button on the edit form, that's what your browser sends to the server: a PATCH request.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up