Search code examples
phptwitter-bootstraplaravellaravel-3

Laravel image submit button


I'd like to know if there is a way to customize the look of a submit button (to be an Image instead) in Laravel 3.

Currently, my submit button code looks like this :

{{ Form::open('project/delete', 'DELETE') }}
{{ Form::hidden('id', $project->id) }}
{{ Form::submit('Delete project', array('class'=>'btn')); }}
{{ Form::close() }}

And it's doing his job correctly. But I don't see how I could customize the submit button and put it as a bootstrap icon for example with ; <i class="icon-trash"></i>

I tried using :

{{ HTML::decode(HTML::link_to_route('project_delete', '<i class="icon-trash"></i>', array($project->id))); }}

But then I have a problem with my route/ function call.


Solution

  • You can't use HTML for the value of an input. If you tried <input type="submit" value='<i class="icon-trash"></i>'> you would see it didn't work. Furthermore, using a link like your second approach won't work because it doesn't actually submit the form.

    Your best bet would be to use a button.

    <button type="submit"><i class="icon-trash"></i></button>