1
00:00:00,570 --> 00:00:01,790
Hello and welcome.

2
00:00:01,850 --> 00:00:08,970
Im sure we are going to had fun for new post in our previous show.

3
00:00:08,970 --> 00:00:20,040
We created an action method in Siham harpo's controller also created a corresponding view that will

4
00:00:20,040 --> 00:00:23,090
enable us to create or add new post.

5
00:00:23,260 --> 00:00:27,830
So we need to do a nice ad form to that template.

6
00:00:28,420 --> 00:00:32,500
So this is our application as it looks at the moment we're currently in.

7
00:00:32,510 --> 00:00:36,230
If you hear coord new dotty's Mail.

8
00:00:36,370 --> 00:00:37,210
E r b.

9
00:00:37,230 --> 00:00:46,140
So we're going to add form to these few that will reflect here so any changes as you're developing any

10
00:00:46,140 --> 00:00:52,190
changes you make is reflected automatically through the application browser here.

11
00:00:52,200 --> 00:00:59,100
So when this goes wrong if you do something that these server is not happy about the server will complain

12
00:00:59,670 --> 00:01:01,770
and you see the effect on the screen.

13
00:01:01,770 --> 00:01:06,340
The screen will probably show error messages and stuff like that by the moment.

14
00:01:06,450 --> 00:01:07,300
We are good.

15
00:01:07,320 --> 00:01:09,770
Everything seems to be working all right.

16
00:01:09,810 --> 00:01:19,530
So let's add here for to create a form within this template we all need to use a form builder and the

17
00:01:19,560 --> 00:01:31,400
primary form build for reals is provided by he help a method called form on the score for a help.

18
00:01:31,430 --> 00:01:40,180
Third is basically him method written for The View so it is primarily designed to be reusable.

19
00:01:40,200 --> 00:01:47,770
Anyway within your application or website and it helps cleans up the code inside the view.

20
00:01:47,790 --> 00:01:53,400
By separating it out from some of the logic.

21
00:01:53,400 --> 00:02:01,590
So I added the form underneath the heading here bit here if you don't want to type this all out.

22
00:02:01,650 --> 00:02:08,100
I've got I've got it in a text file which will be also available as a resource to download so you can

23
00:02:08,100 --> 00:02:09,210
just copy and paste.

24
00:02:09,210 --> 00:02:13,830
If you don't want to type things out so this is the forum here.

25
00:02:13,830 --> 00:02:21,280
This is the form helper the form on this call for this is what is known as form help.

26
00:02:21,480 --> 00:02:26,490
So I'll just run through the bits and pieces of the form.

27
00:02:26,950 --> 00:02:33,890
So when you call the form helper which is the form on the score for this one here.

28
00:02:33,920 --> 00:02:34,730
That's from L..

29
00:02:34,760 --> 00:02:43,140
But what you do you need to also pass it and identify an object for the form.

30
00:02:43,290 --> 00:02:45,260
If a puzzle is an object.

31
00:02:45,360 --> 00:02:54,310
In this case I've passed it post identify an object is post which is what I've specified there.

32
00:02:54,960 --> 00:03:05,250
So what that tells the form helper A tells of form from the what the form is for the K and inside the

33
00:03:05,250 --> 00:03:09,340
block for this method of action.

34
00:03:09,390 --> 00:03:15,170
The form builds an object is represented by F which is this pair here.

35
00:03:15,180 --> 00:03:19,910
This is a form that object represented by that.

36
00:03:20,100 --> 00:03:30,720
And basically what that does is used to build two labels and also all to text fields one each for the

37
00:03:30,720 --> 00:03:37,240
title and the text off pulsed and also all for the body.

38
00:03:37,290 --> 00:03:40,930
As you can see here this this will build.

39
00:03:41,010 --> 00:03:48,150
This is a label full title which is the label and then detects where you entered it took.

40
00:03:48,300 --> 00:03:54,380
And I also got another one here that will create a label called Body and the text area.

41
00:03:54,460 --> 00:04:03,750
You create a body form for you to enter the text for the body and then you've got the the object here

42
00:04:03,840 --> 00:04:06,560
also creates the sub meet.

43
00:04:06,990 --> 00:04:07,350
Okay.

44
00:04:07,370 --> 00:04:13,310
It also creates the submit button that were maybe for you to submit the form.

45
00:04:13,950 --> 00:04:17,190
So let's save the form and have a look.

46
00:04:17,340 --> 00:04:18,850
Fix thief or.

47
00:04:19,520 --> 00:04:23,760
And if you just refresh this you should see the form hopefully.

48
00:04:23,810 --> 00:04:24,780
There you go.

49
00:04:25,020 --> 00:04:27,330
So you should see a form like this.

50
00:04:27,330 --> 00:04:32,370
If yours doesn't come up then we need to troubleshoot what the issue is.

51
00:04:32,370 --> 00:04:36,080
So this is what your form should look like.

52
00:04:36,150 --> 00:04:40,140
So we've generated a font used in the form helper.

53
00:04:40,890 --> 00:04:44,940
However there is a slight problem with the form.

54
00:04:45,180 --> 00:04:53,460
If I inspect the hasty mail that is generated for this form and we can do that by right clicking and

55
00:04:53,460 --> 00:04:56,620
click on the ended page source Okay.

56
00:04:57,930 --> 00:04:59,840
So by viewing this page here you can see.

57
00:04:59,880 --> 00:05:08,150
I see that the action attribute for the form he is pointing to the coolest new gear.

58
00:05:08,190 --> 00:05:10,200
That's the action here.

59
00:05:10,200 --> 00:05:11,190
That's the form.

60
00:05:11,250 --> 00:05:14,880
Look at the action attribute here pointing to post new.

61
00:05:14,880 --> 00:05:19,540
That's a problem because he's pointing to the same page we are currently on.

62
00:05:19,860 --> 00:05:27,730
This current root should only be used to display the form 4 in New post.

63
00:05:27,960 --> 00:05:36,280
So what we need to do we need to put an entry in siby form just to edit the path we need to insert.

64
00:05:36,360 --> 00:05:39,450
Here you are real inside the form.

65
00:05:39,870 --> 00:05:42,900
So the form needs to use K different.

66
00:05:42,930 --> 00:05:48,830
You are real in order to go somewhere else so that it goes away from this page.

67
00:05:48,840 --> 00:05:58,620
Once it's been submitted so this can be done by inserting the upfront so free here on the form does

68
00:05:58,670 --> 00:06:00,130
call form help.

69
00:06:00,180 --> 00:06:02,500
We just need to update the post object.

70
00:06:02,520 --> 00:06:06,480
We just need to put a comma and type in the word.

71
00:06:06,780 --> 00:06:09,670
You are L..

72
00:06:10,570 --> 00:06:18,760
Call on and then type name post on the score PA

73
00:06:21,400 --> 00:06:23,030
space.

74
00:06:23,760 --> 00:06:31,590
Okay so that was just add this added that you are real call on post on this call parse so now that's

75
00:06:31,650 --> 00:06:35,870
where it will go right down stay on the same page.

76
00:06:35,910 --> 00:06:37,930
Let me say that.

77
00:06:39,090 --> 00:06:47,220
KING So what's happening here is that the post does call PAFF helper which is this one paused on the

78
00:06:47,220 --> 00:06:47,910
scope path.

79
00:06:47,900 --> 00:06:50,340
Help is pass today.

80
00:06:50,370 --> 00:06:52,110
You are a real option.

81
00:06:52,250 --> 00:06:56,130
Okay so let's see what we've just done.

82
00:06:56,130 --> 00:07:01,360
Click save or let's make sure everything you're running.

83
00:07:01,530 --> 00:07:02,400
Yes.

84
00:07:02,600 --> 00:07:04,170
Are pages to go in.

85
00:07:04,350 --> 00:07:07,650
So that's it for this lecture in the next election.

86
00:07:08,040 --> 00:07:17,340
We're going to explore the droughts that were generated when we added a post has a resource and also

87
00:07:17,340 --> 00:07:24,660
we are going to try and make some inputs into lose form and see what happens.

88
00:07:24,660 --> 00:07:25,720
Thanks for watching.

89
00:07:25,830 --> 00:07:26,960
And by phone now.
