Part 11 - 'Create' function and Forms in Laravel [How to Build a Blog with Laravel 5 Series]

preview_player
Показать описание
Our two main goals of this video are to get the “Create” action of our CRUD working and to get blade forms set up as well so we can easily build and manage forms in our views using the blade templating engine.

Now in past versions of Laravel (version 4 and earlier) we had built in access to form helpers in our views. However in all the infinite wisdom of the developers behind the Laravel project, they have decided that it will not be included going forward.

We can still use form helpers, but we will need to bring the code in ourselves. There is a website called “Laravel Collective” who has worked to maintain these missing code snippets for us so we can still load them and use them in our projects.

Once we have this done, we can start using the Form class. These are the methods we use in this tutorial.

1.Form::label(‘id’, ‘value’)
2.Form::text(‘name’, ‘value’, [options])
3.Form::textarea(‘name’, ‘value’, [options])
4.Form::submit(‘value’, [options])

--- LINKS ---

--- MORE FROM THIS SERIES ---

--- FOLLOW ME ---

---

Tags: Laravel 5 Framework Tutorial Easy to learn. Best tut about Laravel. Build a blog with Laravel Tutorial. Beginner tutorial. How to video. PHP framework easy best tutorial.
Рекомендации по теме
Комментарии
Автор

Its nice to see people helping each others here and Thank you Jacurtis

amirkamalian
Автор

Code for not using the form helper.
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h1>Create New Post</h1>
<hr>
<form method="POST" action="{{ route('posts.store') }}">
<div class="form-group">
<label name="title">Title:</label>
<input id="title" name="title" class="form-control">
</div>
<div class="form-group">
<label name="body">Post Body:</label>
<textarea id="body" name="body" rows="10"
</div>
<input type="submit" value="Create Post" class="btn btn-success btn-lg btn-block">
<input type="hidden" name="_token" value="{{ Session::token() }}">
</form>
</div>
</div>

sodomousprime
Автор

I just want to say thank you again for making this videos so much fun, as someone who is teaching himself how to code and has to find what ever resources he can to learn not only basic language syntax but also how libraries, frameworks and everything in between works together, this has been by far one of the most relaxing and fun experience I have had.

boyeverjoy
Автор

If your are watching this in 2018:
navigate to the folder you have saved your project
open a new terminal window and type: composer require "laravelcollective/html"

SmartyMatic
Автор

I want to send a big thanks to Admin of this Videos. This is an excellent tutorial I've ever seen before

tranbinhtam
Автор

I salute to you Sir! Thanks for amazing series. And for the people that are watching it in 2018, the code in tutorial is almost the same between this 5.2 and 5.5

CroGmaz
Автор

Very interesting process for forms in Laravel. Glad you walked through this as it's not very intuitive.

kamaboko
Автор

I'm currently on this video in your series and their all brilliant, I can't wait to carry on, though I seem to be getting an error when trying to access the create page,

The error is NotFoundHttpException in RouteCollection line 161,

I read that it's about the routes file, where we created the line routes resources, it's all written correctly, the Post Controller is all as it should be, i just can't source out what it is, and I don't want to continue watching without fixing this because I wouldn't be able to follow along,

I would really appreciate any help,

Thanks

Saibot
Автор

If anyone have problem with this style of making form then i have been through this project and made form in easy way so contact me for the form code and other related changes that is required to be made . First of all, thank you much sir for teaching the fabulous way of doing project with Laravel :)

mekhan
Автор

I've been following this series from the beginning and really learning a lot. I have a question about the routing with the post controller. I set up my site using the sections and partials in your previous tutorials and everything was working fine. The issue I'm having now is all of my resource files are not making it to my pages in the Post controller. I'm getting the errors cannot be found". I put the css and javascript files in public -> css and public -> js. How do I correct this?

diverchuck
Автор

Awesome job. Lot easier then laracasts. Thanks a lot for such a quality video.

imranhossainshoikoth
Автор

Thanks for the tutorials man. I followed your tutorial series up to here. I managed to install the Collectives for HTML, but even then my form still didn't work. It doesn't submit, so I'm trying other alternative tutorials. THe method that you use isn't easier, I understand why Laravel discotinued. I haven't seen anyone code this way either. It would be awesome if you could do a more updated series on Laravel. Anyways many thanks. I've learned a lot from series up to this point.

joamimynhardt
Автор

in my case it gives me an error... i'm using laravel 7.17 and it tells me ( Your requirements could not be resolved to an installable set of packages. ) why?

ivangismondi
Автор

for new users, it's really easy don't be intimidated, the installation is just a single command in new versions you don't have to add a provider and dependency + go to documentation and copy the commands it's that easy

manafa.b
Автор

Dude, your voice is perfect with 1.5x speed :)
Anyway, thank's for the tutorial!

vighiosif
Автор

I am getting an error when I try to load my posts/create page. Not sure what to do. all my code worked until now. Error message is: FatalThrowableError in PostController.php line 45:
Parse error: syntax error, unexpected ''body'' (T_CONSTANT_ENCAPSED_STRING), expecting ')'

jonathanrautenbach
Автор

hi, been following all your videos. it's great. A question if you or anyone else can answer. While creating a new post, assume I have a dropdown to select a category for my post.
What is the form helper for that and how to prefill with data pulling from the database table.

bushrakhalid
Автор

I found in the documentation. Its something like
{{ Form::select('account_id', ['1' => 'Account1', '2' => 'Account2'], null, ['class' => 'span11']) }}

However, How to fill this <option> List Dynamically from the database table?

bushrakhalid
Автор

I really feel good with your tutorials..

samueloladimejibello
Автор

Hello Sir, after I use PostController and then the CSS doesn't work, other beside this is working fine. Can you help ?

ChannatTem