Outils pour utilisateurs

Outils du site


devweb:laravel:macros (lu 29645 fois)

Les Macros

Save the following code to app/macros.php (this file doesn’t exist by default so create it):

HTML::macro( 'submit', function( $value = null, $options = array() )
{
    $options = array_merge( $options, array( 'class' => 'btn btn-info' ) );
    return Form::input( 'submit', null, $value, $options );
});

Now include macros.php by adding require app_path().’/macros.php’; to the bottom of app/start/global.php.

And now in your views, instead of:

Form::submit( 'Submit', array( 'class' => 'btn btn-info' ) );

Use:

HTML::submit( 'Submit' );
devweb/laravel/macros.txt · Dernière modification: 04-01-2015 23:32 de edmc73