Is it possible to put a bootstrap glyphicon inside of a {{ Form::submit(' ')}} - Laravel
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Beyond Text: Putting Bootstrap Glyphicons Inside Laravel Form Submissions
As developers working with the Laravel ecosystem, we often find ourselves balancing the elegance of server-side logic with the necessity of crafting beautiful, interactive front-end experiences using CSS frameworks like Bootstrap. A common challenge arises when trying to embed complex HTML elements, such as a Bootstrap Glyphicon, directly into standard form submission helpers like Form::submit().
The question we are addressing today is: Is it possible to put a Bootstrap glyphicon inside of a {{ Form::submit(...) }} in Laravel?
The short answer is that while technically possible through raw string injection, it is generally considered an anti-pattern. The correct approach involves understanding how Laravel's form helpers work and leveraging the power of Blade templating to construct the desired structure cleanly and securely.
Understanding the Conflict: String vs. HTML
Let's examine why your initial attempt doesn't work as expected. When you use methods like Form::submit('Delete this User', ...) or Form::button(...), these methods are designed to accept a simple string for the button's visible text. They handle the wrapping of that string into the appropriate <input type="submit"> or <button> tag on their own.
When you try to inject raw HTML, like in your second example:
{{ Form::submit('<i class="glyphicon glyphicon-delete"></i>', array('class' => '')) }}
You are essentially telling Laravel to insert the string <i class="glyphicon glyphicon-delete"></i> as the content of the submit element. While this might render in some contexts, it bypasses the intended structure of the helper and can lead to issues with proper form handling, accessibility, and security (especially if not properly escaped).
The core issue is that Laravel form helpers are designed for simplicity; complex structural elements should be handled by the view layer itself.
The Correct Approach: Leveraging Blade for Structure
Instead of trying to force the icon inside the submission string, the best practice in a Laravel application is to let Blade handle the complete rendering of the button structure, including the icon, as part of the overall form layout. This ensures better separation of concerns and maintainability.
Here is how you achieve the desired result elegantly:
Method 1: Constructing the Button Directly with Blade
Instead of relying solely on Form::submit(), we can use standard Blade syntax to build the button exactly as we want it, ensuring the icon is correctly positioned alongside any text.
{{-- Example using a standard <button> structure --}}
<form method="POST" action="/users">
@csrf
<button type="submit" class="btn btn-warning">
<i class="glyphicon glyphicon-delete"></i> Delete this User
</button>
</form>
In this scenario, we are no longer relying on the Form facade for the entire button structure. We are using Blade to define the precise HTML elements. This approach is superior because it gives you full control over spacing, alignment, and interaction behavior. If you are dealing with complex UI components within your Laravel views—whether managing Eloquent relationships or handling complex requests—focusing on well-structured Blade templates, as promoted by practices at laravelcompany.com, is crucial.
Method 2: Using Form Helpers for the Action, and Blade for Content
If you absolutely need to use a form helper (perhaps for specific validation or redirection related to Form::submit()), you can separate the action from the visual presentation:
<form method="POST" action="/users/delete">
@csrf
{{-- The submission happens here, usually triggering a standard input --}}
<input type="submit" value="Delete User" class="btn btn-warning">
</form>
{{-- If you must place the icon near it: --}}
<div class="d-flex align-items-center">
<i class="glyphicon glyphicon-delete mr-2"></i> {{-- Use margin utilities for spacing --}}
<input type="submit" value="Delete User" class="btn btn-warning">
</div>
Notice how Method 2 solves the problem by treating the icon and the text as sibling elements within a parent container (<div>). This is far more robust than trying to inject an icon into a single string parameter of a form helper.
Conclusion
In summary, while you can technically force raw HTML strings into Laravel Blade views, it defeats the purpose of using framework helpers. For building dynamic interfaces in Laravel, the golden rule is to use the view layer (Blade) to construct the final HTML structure. By shifting your focus from trying to manipulate a string passed to Form::submit() to directly defining the necessary <button> or <a> elements with embedded icons, you ensure your application remains clean, secure, and adheres to modern web development best practices.