mybb2 icon indicating copy to clipboard operation
mybb2 copied to clipboard

Remove the `laravelcollective/html` package

Open euantorano opened this issue 8 years ago • 14 comments

I'm not sure what the original intent was, but we should remove laravelcollective/html. It makes things unduly complex and difficult. For instance, one is limited when opening a form to the following:

{{ form_open({'route': ['topics.reply', topic.id, topic.slug], 'method': 'post', 'id': 'topicreply'}) }}

You cannot instead do:

{{ form_open({'route': ['topics.reply', {'id': topic.id, 'slug': topic.slug}], 'method': 'post', 'id': 'topicreply'}) }}

Constructing a <form> tag isn't difficult, so there's not much use for the library in my opinion.

euantorano avatar Mar 17 '16 18:03 euantorano

You could use

form_open({'url': url_route('topics.reply', {'slug': topic.slug, 'id': topic.id}), 'method': 'post', 'id': 'quickreply'})

to generate forms ^^ looks ugly ...

Nik101010 avatar Mar 17 '16 22:03 Nik101010

Yeah, it's easier to just use the proper tag IMO. Gets rid of a dependency too hopefully.

euantorano avatar Mar 17 '16 22:03 euantorano

Maybe it's easier for

https://github.com/mybb/mybb2/blob/master/resources/views/admin/partials/users/profile_field_form.twig#L12 for example

Nik101010 avatar Mar 17 '16 22:03 Nik101010

Yeah, we could probably define a twig extensions for select boxes that just renders a template.

euantorano avatar Mar 18 '16 10:03 euantorano

I personally prefer to use laravelcollective/html instead of using <form>... (it's easier for CSRF, selects and ...)

We can ask @laravelcollective to add a way to use

{{ form_open({'route': ['topics.reply', {'id': topic.id, 'slug': topic.slug}], 'method': 'post', 'id': 'topicreply'}) }}

ATofighi avatar Mar 18 '16 15:03 ATofighi

Either way, we need to be able to use a hash rather than relying on positional arguments.

euantorano avatar Mar 18 '16 15:03 euantorano

@ATofighi there is the csrf_field() function for generating a csrf form field in laravel 5.2 ... no need to use laravelcollective/html for this ... A whole package just for two functions ... Imo twig extensions for form opening and selects are a better idea ...

Nik101010 avatar Mar 18 '16 16:03 Nik101010

We could always do <form action="{!! route('topics.reply', ['id' => topic.id, 'slug' => topic.slug]) !!}" method="post">, that would be the proper way of doing it.

xaoseric avatar Mar 30 '16 14:03 xaoseric

Yep, that's how I've been fixing it personally.

On 30 Mar 2016, at 15:51, Eric Hocking [email protected] wrote:

We could always do

, that would be the proper way of doing it.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub

euantorano avatar Mar 30 '16 15:03 euantorano

It's will be removed and all forms will be created using normal html tags? I've started doing user management in ACP. What way i should create forms?

Matslom avatar Jun 26 '16 16:06 Matslom

Yes, that's the plan. To create forms, you should write the normal HTML for a form, and use {{ url_route() }} to crate the URL the form submits to 😄

euantorano avatar Jun 26 '16 17:06 euantorano

I agree with removing this is makes it unnecessarily complex, when has there even been a problem with writing standard HTML?

036 avatar Nov 18 '16 13:11 036

@036 Writing HTML isn't a problem but populating a form manually is more difficult. The package provides a convenient way to bind models to forms: https://laravelcollective.com/docs/5.3/html#form-model-binding

Stefan-MyBB avatar Nov 18 '16 13:11 Stefan-MyBB

Using laravel collective with vue is really big problem and not working together so if you want in the future use vue, you will need replace form created with collective to html forms.

AdrianKuriata avatar Oct 13 '17 20:10 AdrianKuriata