-1

I'm using laravel 5.2 and blade is used for views. There are many repeated codes in bootstrap syntax in many forms. The following code is just an example:

<div class="row">
    <div class="col-lg-4  col-md-4 col-sm-4 col-xs-12">
        <label for="product">Product<span class="require">*</span></label>
    </div>
    <div class="col-lg-4  col-md-4 col-sm-4 col-xs-12">
        <input type="text" required class="form-control" id="product" name="product"  value="{{ isset($product)? $product->product_name:Request::old('product_name') }}"/>
        <p class="text-danger">{{$errors->first('product_name')}}</p>
    </div>
</div>

In that case, bootstrap class col-lg-4 col-md-4 col-sm-4 col-xs-12 and col-lg-4 col-md-4 col-sm-4 col-xs-12 are repeated in one forms and all other forms. How to remove that repeated codes. Thanks in advance.

Shihab
  • 199
  • 1
  • 16
Aye
  • 19
  • 8
  • 1
    Can you clarify the question? You only need to use `col-sm-4` which is the same as `col-lg-4 col-md-4 col-sm-4 col-xs-12`, but I don't understand "How to remove that repeated codes." – Carol Skelly Feb 22 '17 at 13:15
  • I'm just new to bootstrap and I define grid system for all divices, large, medium, small. Now I know just defining col-sm-4 works well. But I have about 14 forms and all forms elements need to define like bootstrap class and I think that codes are repeated and how to simplify the code. Thanks for your comment. – Aye Feb 22 '17 at 14:12

1 Answers1

0

You could create in PHP a global variable string containing your col-lg-4 ... And then, pass it every time to your templates so you juste have to call that variable in each .

Or use a tool like LESS, like describe in this post . It would allow you to declare a CSS class that would "inherit" from these css classes. In any case, you have to at least write one element in the class section.

Community
  • 1
  • 1
Dimitri Bosteels
  • 381
  • 4
  • 12