Search code examples
htmllaraveltwitter-bootstraplaravelcollective

Adding Bootstrap tooltips into form label


I trying to make tooltips into laravelcollective

<div class="form-group col-sm-4">
  {!! Form::label('exchange_id', 'Exchanges:') !!}
  {!! Form::select('exchange_id', [''=>'Choose Options'] + $exchanges , null, ['class'=>'form-control', 'id'=>'exchange', 'name'=>'exchange_id',  'onchange' => 'all_function()'])!!}
</div>

In the above select box, {!! Form::label('exchange_id', 'Exchanges:') !!} I want to put Bootstrap tooltips like, Exchanges ? : with question mark.
How can I do this?


Solution

  • You can add attribute to label tag, data-toggle="tooltip" and title="Exchanges ?"

    <div class="form-group col-sm-4">
     {!! Form::label('exchange_id', 'Exchanges:', ['data-toggle' => 'tooltip', 'title' => 'Exchanges ?']) !!}
     {!! Form::select('exchange_id', ['' => 'Choose Options'] + $exchanges, null, ['class' => 'form-control', 'id' => 'exchange', 'name' => 'exchange_id', 'onchange' => 'all_function()'])!!}
    </div>
    

    Need bootstrap plugin and use like it

    $(function () {
      $('[data-toggle="tooltip"]').tooltip()
    })
    

    Tooltips: http://getbootstrap.com/docs/4.1/components/tooltips/

    Demo: http://jsfiddle.net/xL1vteoj/