Hello and welcome.
Im sure we are going to had fun for new post in our previous show.
We created an action method in Siham harpo's controller also created a corresponding view that will
enable us to create or add new post.
So we need to do a nice ad form to that template.
So this is our application as it looks at the moment we're currently in.
If you hear coord new dotty's Mail.
E r b.
So we're going to add form to these few that will reflect here so any changes as you're developing any
changes you make is reflected automatically through the application browser here.
So when this goes wrong if you do something that these server is not happy about the server will complain
and you see the effect on the screen.
The screen will probably show error messages and stuff like that by the moment.
We are good.
Everything seems to be working all right.
So let's add here for to create a form within this template we all need to use a form builder and the
primary form build for reals is provided by he help a method called form on the score for a help.
Third is basically him method written for The View so it is primarily designed to be reusable.
Anyway within your application or website and it helps cleans up the code inside the view.
By separating it out from some of the logic.
So I added the form underneath the heading here bit here if you don't want to type this all out.
I've got I've got it in a text file which will be also available as a resource to download so you can
just copy and paste.
If you don't want to type things out so this is the forum here.
This is the form helper the form on this call for this is what is known as form help.
So I'll just run through the bits and pieces of the form.
So when you call the form helper which is the form on the score for this one here.
That's from L..
But what you do you need to also pass it and identify an object for the form.
If a puzzle is an object.
In this case I've passed it post identify an object is post which is what I've specified there.
So what that tells the form helper A tells of form from the what the form is for the K and inside the
block for this method of action.
The form builds an object is represented by F which is this pair here.
This is a form that object represented by that.
And basically what that does is used to build two labels and also all to text fields one each for the
title and the text off pulsed and also all for the body.
As you can see here this this will build.
This is a label full title which is the label and then detects where you entered it took.
And I also got another one here that will create a label called Body and the text area.
You create a body form for you to enter the text for the body and then you've got the the object here
also creates the sub meet.
Okay.
It also creates the submit button that were maybe for you to submit the form.
So let's save the form and have a look.
Fix thief or.
And if you just refresh this you should see the form hopefully.
There you go.
So you should see a form like this.
If yours doesn't come up then we need to troubleshoot what the issue is.
So this is what your form should look like.
So we've generated a font used in the form helper.
However there is a slight problem with the form.
If I inspect the hasty mail that is generated for this form and we can do that by right clicking and
click on the ended page source Okay.
So by viewing this page here you can see.
I see that the action attribute for the form he is pointing to the coolest new gear.
That's the action here.
That's the form.
Look at the action attribute here pointing to post new.
That's a problem because he's pointing to the same page we are currently on.
This current root should only be used to display the form 4 in New post.
So what we need to do we need to put an entry in siby form just to edit the path we need to insert.
Here you are real inside the form.
So the form needs to use K different.
You are real in order to go somewhere else so that it goes away from this page.
Once it's been submitted so this can be done by inserting the upfront so free here on the form does
call form help.
We just need to update the post object.
We just need to put a comma and type in the word.
You are L..
Call on and then type name post on the score PA
space.
Okay so that was just add this added that you are real call on post on this call parse so now that's
where it will go right down stay on the same page.
Let me say that.
KING So what's happening here is that the post does call PAFF helper which is this one paused on the
scope path.
Help is pass today.
You are a real option.
Okay so let's see what we've just done.
Click save or let's make sure everything you're running.
Yes.
Are pages to go in.
So that's it for this lecture in the next election.
We're going to explore the droughts that were generated when we added a post has a resource and also
we are going to try and make some inputs into lose form and see what happens.
Thanks for watching.
And by phone now.