6.7 Form Macros
Laravel has provided many different input methods, but what if we need something a little more
custom? Fortunately Laravel has provided the macro() method to allow us to create our own
input generators.
By passing an input name and a closure to the macro() method we can define our own input
generator, let’s take a look.
1 <?php
2
3 Form::macro('shoe_size', function() {
4 return '<input type="shoe_size" />';
5 });
Now we can use the Form class to generate our shoe size field in the same way as any other
input, for example..
1 <?php echo Form::shoe_size(); ?>
If you need to use parameters, simply add them as parameters to the closure. Enjoy creating
your own unique input generators!