Package Data | |
---|---|
Maintainer Username: | lucasvdh |
Maintainer Contact: | lucasvanderhave@gmail.com (Lucas van der Have) |
Package Create Date: | 2016-08-30 |
Package Last Update: | 2017-07-12 |
Language: | CSS |
License: | MIT |
Last Refreshed: | 2024-11-15 15:09:10 |
Package Statistics | |
---|---|
Total Downloads: | 1,715 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A useful set of HTML and Form macros with corresponding CSS and Javascript resources. Made for Bootstrap.
Check out the 4.0 branch for Laravel 4 support.
View the examples.
composer require lucasvdh/laravelmacros:5.*
Or add a requirement to your project's composer.json
"require": {
"lucasvdh/laravelmacros": "5.*"
},
Edit the config/app.php
file. Append the following to the providers
array:
'providers' => [
// ...
Lucasvdh\LaravelMacros\MacroServiceProvider::class,
// ...
],
If you didn't have the laravelcollective/html
package yet, be sure to add that service provider too:
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
And register the aliases:
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
$ php artisan vendor:publish --provider="Lucasvdh\LaravelMacros\MacroServiceProvider"
$ php artisan vendor:publish --provider="Lucasvdh\LaravelMacros\MacroServiceProvider" --tag="scripts"
$ php artisan vendor:publish --provider="Lucasvdh\LaravelMacros\MacroServiceProvider" --tag="styles"
$ php artisan vendor:publish --provider="Lucasvdh\LaravelMacros\MacroServiceProvider" --tag="images"
The CSS and Javascript files will be published to public/css
and public/js
.
Make sure to include these in the view where you want to use the macros. You have two choices for including the styles and scripts.
Either you include all the plugins as a minified file.
<html>
<head>
...
<link href="/css/laravel-macros.css" rel="stylesheet">
</head>
<body>
...
<!-- Include Javascript at the end of body to improve page load speed -->
<script src="/js/laravel-macros.js" type="text/javascript"></script>
</body>
</html>
Or you include specific plugins.
<html>
<head>
...
<link href="/css/chosen.css" rel="stylesheet">
<link href="/css/tags-input.css" rel="stylesheet">
</head>
<body>
...
<!-- Include Javascript at the end of body to improve page load speed -->
<script src="/js/chosen.jquery.min.js" type="text/javascript"></script>
<script src="/js/tags-input.js" type="text/javascript"></script>
<!-- IMPORTANT this file is required for the plugins to function -->
<script src="/js/laravel-macros-app.js" type="text/javascript"></script>
</body>
</html>
You can now use the macros and all should work. Customization of the CSS and Javascript files should be straight forward.
Below, a few examples are given how to use these macros:
Date picker
{!! Form::datepicker('field_name', $default, ['class' => 'some-class']) !!}
Chosen select
{!! Form::chosen('field_name', $default, $list, ['class' => 'some-class']) !!}
Material checkbox
{!! Form::materialCheckbox('field_name', $checked, 'This is the checkbox text', 'value', ['class' => 'some-class']) !!}
Material radio
{!! Form::materialRadio('field_name', $default, $options = ['value' => 'label'], ['class' => 'some-class']) !!}