I'm trying to get the font awesome icon to show in my delete button in my laravel form.
Here is the delete button
{{ Form::submit('<i class="fa fa-pencil"></i> Delete', array('class' => 'btn btn-danger', 'role' => 'button')) }}
{{Form::button(' Se connecter<i class="fa fa-key icon-on-right"></i>', array(
'type' => 'submit',
'class'=> 'pull-right btn btn-primary',
))}}
When you use Form::submit, the content is always escaped. You can use Form::button instead, which does not escape the content.
Your code can be tweaked to:
{{ Form::button('<i class="fa fa-pencil"></i> Delete', ['class' => 'btn btn-danger', 'role' => 'button', 'type' => 'submit']) }}
Also make sure to set type = submit while using Form::button.
Check out my previous answer.
Basicly laravel allows to decode any html with {{HTML::decode(<insert Form button here>) }}
Unfortunately the form builder is always going to escape it's content. Furthermore, the submit input type only supports text content, not HTML. You need to use a button element to display HTML content.
<button class="btn btn-danger"><i class="fa fa-pencil"></i> Delete</button>
Related
We can send the values of text as follows in laravel collectives? Is it possible to send the value of a button in laravel collecctives?
{{Form::text('element_id','',['class'=>'form-control'])}}
May the following will do the trick
{{ Form::button('Delete', array('class' => 'btn btn-danger delete', 'type' => 'button', 'value' => 'the value')) }}
I am very new to Laravel. On my blade I have to forms, First has 11 checkboxes and save button. Basically a user comes to check inputs he needed and clicks save, which takes to controller and stores the values. Now, I have 'accept' button which is completely separate function in controller, but I still need the values from input fields. How would I pass the values from different form.
Example:
{{ Form::checkbox('shopping['.$current->id.']', true, $shopping_cart->getPresence($current->id), ['disabled']) }}
{!! Form::button('<i class="fas fa-btn fa-save"></i>Save', ['type' => 'submit', 'class' => 'btn btn-primary']) !!}
</div>
#endif
{!! Form::close() !!}
{!! Form::model($shipping, [ 'method' => 'POST', 'action' => ['Shopping#storeAcceptShipping', $shopping->id]]) !!}
{!! Form::close !!}
You must use hidden fields y another form. When you send the first form, get in Controller with a standard request and serialize the data like:
$data_form1_serialized = serialize($request->all());
after return the view with this serialized data
return view('form2',compact("data_form1_serialized");
In view form2 make a hidden input with value $data_form1_serialized
{!! Form::model($shipping, [ 'method' => 'POST', 'action' => ['Shopping#storeAcceptShipping', $shopping->id]]) !!}
{!! Form::hidden('data_form1', $data_form1_serialized) !!}
{!! Form::close !!}
OR
Use Vue or(something JS) display a form with tabs o a form step by step, and when all the form is complete part1, part2 etc. Send to Controller. This is for me the right way.
Below is my submit button code.
{!! Form::submit('Update', array('class'=>'btn btn-primary','style'=>'width: 200px')) !!}
I want to change that by adding onclick event as below.
onclick="if( ! confirm('Are you sure you want to delete?')){return false;}">
How to code that in laravel?
If you're not using the jQuery then you can add it to array like:
{!! Form::submit('Update', array(
'class' => 'btn btn-primary',
'style' => 'width: 200px',
'onclick' => "if( ! confirm('Are you sure you want to delete?')){return false;}"
)) !!}
I can't seem to find a way to put image as submit button in blade, is there a way to do this?
{!! Form::submit('Search', array('class'=>'btn')) !!}
Form::input should do the trick:
{!! Form::input('image', 'Search', array('class'=>'btn', 'src' => '...')) !!}
You can create the submit with pure html instead of laravelcollective like that
<input type="image" src="sourse for image" width="48" height="48" alt="Submit" />
For Laravel Collective version 6.2 the solution This small example shows the sending of a variable by means of a button with an image (src='../path/to/file) using the 'submit' passing as parameters the dimensions of the button (30,30).
Note: var_to_send can have a string like $ansver - > 'Hello World' or another value and it will pass it from the controller and it will print it.
// new.blade.php
{!! Form::open([ 'action'=> 'StorageController#save', 'method' => 'POST', 'files' => true]) !!}
{!! Form::hidden('var_to_send', $answer) !!}
{!! Form::image(url('../img/A.png'), 'submit', ['width' => '30', 'height' => '30']) !!}
{!! Form::close() !!}
// StorageController.php
class StorageController extends Controller
{
public function save(Request $request)
{
return $request->input('var_to_send');
}
}
// route wep.php
Route::post('storage/create', 'StorageController#save');
I am trying to render a datepicker in the form created by laravel tags. So far, nothing else is showing except a regular text field.
I've used this for the datepicker. And I did the below in the form:
<p>{{ Form::text('dob', '', array('class' => 'form-control','placeholder' => 'تاريخ الميلاد', 'data-datepicker' => 'datepicker')) }}</p>
Nonetheless, I am only getting this:
What is the recommendation here? I also added the css and js to the header so all should be in place.
Thanks,
Update: calling datepicker js function in the footer.blade.php where all other calls are:
{{ HTML::script('/public/assets/js/bootstrap-typeahead.js') }}
{{ HTML::script('/public/assets/js/bootstrap-datepicker.js') }}
<script>
$('.datepicker').datepicker()
</script>
This still didn't change anything.
Use an id to initialize the datepicker
{!! Form::input('date', 'dob', date('d-m-Y'), ['class' => 'form-control', 'id' => 'dob', 'data-date-format' => "dd-mm-yyyy"]) !!}
and use this javascript
$('#dob').datepicker();