Laravel Classroom image

Prashant  Nigam / Student / Web Technology

To post your Question Join Classroom
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5 | 6 | 7|

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
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!


Prashant  Nigam

Skills    Laravel

Qualifications :-
Location :-,,,

  Students (0)