Search code examples
htmllaravelscaffolding

specifying html markup when using Laravel scaffolding


Ive built the all the views (html, css, jquery) for a web app and now im starting work on the back end, using Laravel / Mysql.

I recently came across scaffolding in Laravel, similar to Ruby on Rails, which is great, but the forms ive built for my views all contain special classes and markup is there a way to specify the classes and other markup to be applied to form when using scaffolding ?


Solution

  • If I got you correctly, you can set an extra variable on controller, or check URI or route on views, and specify extra classes by looking to the view.

    E.g: In the controller, you can do something like this:

    return View::make('views.myview')->with('type','form');
    

    And in the view, you can use simple if clause(s):

    @if(isset($type))
        <div class="{{$type}}">
    @else
        <div class="default">
    @endif
    

    For adding extra markup and assets to views, I use teeplus/asset, which is ported from Laravel 3 to 4 (old habits die hard :)).

    packagist URL

    documentation