Search code examples
formslaravelbuttonlaravel-bladesubmit-button

Laravel Form: Input Button Not Showing HTML Icon


I'm creating a button with Form at Laravel:

{!! Form::submit('<i class="fa fa-trash"></i>', ["class"=>"btn btn-default"]) !!}

The button text becomes:

<i class="fa fa-trash"></i>

I see only this string, not the icon: how to fix it?


Solution

  • Try to use Form::button instead of Form::submit:

    {{ Form::button('<i class="fa fa-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-default'] )  }}
    

    It will create a button tag with type submit instead of an input tag.

    This way the html of the icon should be rendered inside the tag content and should be visible.

    Instead, by using an input tag like you are doing, the html string of the icon would be printend inside the value attribute of the input tag, and here it couldn't be rendered as valid html