Form is not showing the btn bootstrap class in Laravel Blade - laravel-5.4

I imported "laravelcollective/html":"^5.4.0" and my form is working fine but I have this issue with the btn bootstrap class, it is not showing at all, but labels, text and textarea are.
{!!
...
{{ Form::submit('Create Post', null, array('class' => 'btn btn-success btn-lg btn-block')) }}
...
!!}
I am using Laravel 5.4.
What am I doing wrong? Thanks.

Never mind. I had null as an argument. Working now!

Related

How to design the link in cakephp3 while using reverse routing

How to design the link in cakephp3 while using reverse routing? I have an anchor tag and that has a class but in reverse routing it already has the anchor and it is in array, so how can I design the link like background and add class?
Note: I want to design the anchor tag which name is cancel in my program
<div class="btn btn-secondary waves-effect w-md">
<?=
$this->Html->link(
'Cancel', array('controller' => 'Users', 'action' => 'dashboard')
);
?>
</div>
I have tried to add another array but it didn't work.
Html->link('Edit', array('controller' => 'Users', 'action' => 'edituser'),
array('class' =>"btn btn-custom waves-light waves-effect w-md")
);?>

How to restrict HTML/Javascript insertion in database table Laravel 5.2

I could successfully save html/javascript into the database table and it renders it. This is for the first time I have moved to Laravel, YII frameworks automatically caters it but how can I do the same thing in Laravel?
I don't want to use specific checks all over my application, there must be some centralized approach to do so.
Output:
htmlentities($inputs['first_name']); that does the job but how to do this in the whole app. I don't want to have these checks everywhere.
That's how I render form:
{!! Form::model($companyUser, ['route' => ['updateUserProfile', $companyUser->id], 'method' => 'put', 'class' => 'frm-container']) !!}
<div class="col-lg-5">
{!! Form::controlRequired('text', 0, 'first_name', $errors, 'First Name') !!}
</div>
<div class="col-lg-5">
{!! Form::control('text', 0, 'last_name', $errors, 'Last Name') !!}
</div>
<br clear="all"/>
<div class="col-lg-5">
{!! Form::control('password', 0, 'password', $errors, 'New Password') !!}
</div>
<div class="col-lg-5">
{!! Form::control('password', 0, 'password_confirmation', $errors, 'Confirm Password') !!}
</div>
<br clear="all"/>
<div class="col-lg-12 btn-frm-inner">
<button type="submit" class="btn btn-submit">Update</button>
Cancel
</div>
{!! Form::close() !!}
The code you posted is from the form.
You're not supposed to filter what's going in the database in my opinion. You should simply let anything come and then display it the way you want. So this is fine.
Now as for displaying the data :
{{ }} will escape automatically, while {!! !!} will NOT escape anything.
So when you display the data in your view, you should use the first option.

Define HTML validation attributes with Laravel Blade syntax

I would like to combine the Laravel model binding properties with the easy jQuery Validation plugin, if that is possible.
I can't figure out how to add the 'required' attribute to the blade syntax.
Here is normal form syntax with the "required" attribute:
<input type="text" name="title" required>
Laravel Blade syntax
{{ Form:: text('title', null, array('class' => 'form-control')) }}
Any help would be appreciated.
required is a normal HTML input attribute. The only difference is that it doesn't have different values -- it's either present or it's not, which makes it the so-called boolean attribute.
Anyway, this should do the trick:
{{ Form:: text('title', null, array('class' => 'form-control', 'required' => '')) }}
See more here.

Form inputs not showing the same across browsers

I have this JSFiddle that shows a user registration form. I am using Twitter Bootstrap. I have just realized that it shows fine when using Firefox.
However, when using Chrome or IE, the textfields are slightly above the input-group-addons where I have glyphicons.
How can I make the form inputs show correctly across browsers?
<div class="input-group">
<span class="input-group-addon glyphicon glyphicon-user"></span>
<?php
echo $this->Form->input('username', array('class' => 'form-control',
'placeholder' => 'Username', 'required' => 'required', 'type' => 'text'));
?>
</div>
Move the glyph class out and into their own spans.
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
Always try to keep elements separate from their containers to prevent styles from conflicting with each other.

Zend Framework Form Element

I have this code:
<button type="submit" name="submit" class="btn green pull-right">
Potvrdi <i class="m-icon-swapright m-icon-white"></i>
</button>
How can I make Zend_Form_Element_Button with these attributes? (including tag, it is an icon that goes with the text "Potvrdi" as label on button)
I have done this so far:
$submit = new Zend_Form_Element_Button('submit');
$submit ->setLabel('Potvrdi')
->setAttrib('type', 'submit')
->setAttrib('class', 'btn green pull-right');
Thank you.
The quickest solution is to disable escaping for the label and include the HTML code directly in the label:
$submit = new Zend_Form_Element_Button('submit');
$submit ->setLabel('Potvrdi <i class="m-icon-swapright m-icon-white"></i>')
->setAttrib('type', 'submit')
->setAttrib('class', 'btn green pull-right')
->setAttrib('escape', false);
However, If you plan to use this type of button often in your source code, you should consider writing your own Zend_Form_Element (e.g. My_Form_Element_IconButton) that takes care of adding these tags.