Use <span> inside Form Label in Blade template - html

In html I can use <span> tag inside form label like this:
<label for="name" class="class-name">Name:<span class="required"></span></label>
Using Laravel Blade, the code for label is like this:
{!! Form::label('name','Name:',['class'=>'class-name']) !!}
How can I use <span> inside form label using blade template?

Try this one code:
{!! Html::decode(Form::label('name','Name: <span class="required"></span>')) !!}

Just set the 4th parameter of Form::label to false which is escape_html = false.
{!! Form::label('name','Name: <span class="required"></span>', [], false) !!}

Related

Treeview with --- select option

I'm building a treeview inside my Laravel application but I have a problem with the view. I'm currently getting everything under the same select box, for example:
demo1
demo2
demo3
However, I want this inside select options like:
demo1
--- demo2
------ demo3
Controller:
$categories = Pool::where('parent_id', '=', 0)->get();
$allCategories = Pool::pluck('title','id')->all();
return view('admin.accept', compact(['categories','allCategories']));
View:
<div class="form-group {{ $errors->has('parent_id') ? 'has-error' : '' }}">
{!! Form::label('Pool:') !!}
{!! Form::select('parent_id',$allCategories, old('parent_id'), ['class'=>'form-control', 'placeholder'=>'Kies uw Pool']) !!}
<span class="text-danger">{{ $errors->first('parent_id') }}</span>
</div>
<div class="form-group {{ $errors->has('title') ? 'has-error' : '' }}">
{!! Form::label('Naam:') !!}
{!! Form::text('title', old('title'), ['class'=>'form-control', 'placeholder'=>'Enter Title']) !!}
<span class="text-danger">{{ $errors->first('title') }}</span>
</div>
How can I do this?
How can I build a treeview inside my Laravel application?

How to define hyperlink in Laravel Blade template?

There is a button,which will redirect to a new page after being clicked.
I want to define a hyperlink for this in laravel blade template.
{!! Form::button('<span class="fa fa-arrow-circle-right"></span> Start',
array('class' => 'btn btn-next next-step pull-right'))
!!}
Wrap your button with a form:
<form action="http://example.com">
// button code
</form>
Or:
{!! Form::open(['url' => 'http://example.com']) !!}
// button code
{!! Form::close() !!}
{!! Form::open(['route' => 'route.name']) !!}
// button code
{!! Form::close() !!}
{!! Form::open(['action' => 'Controller#action']) !!}
// button code
{!! Form::close() !!}

Assigning the id in html through the Blade concept. laravel 5.1

here is my code ,
I want to change the radio buttons,label which is associated with the radiobutton id="male". I have tried various ways to do it, but i can't make it work. I want to change the text "Male" in the label associated to the radio button in Blade Laravel 5.1
{!! Form::label('gender','Gender') !!} :
{!! Form::label('lblMale','Male') !!}
{!! Form::radio('sex','male' !!}
{!! Form::label('lblFemale', 'Female') !!}
{!! Form::radio('sex', 'female') !!}
its working properly , but i want on clicking on male label male check box should check and clicking on Female label it should select female checkbox in blade
you can do radio button like this in laravel blade
<label for="male">
<input name="male" id="male" value="male" type="radio">
Male
</label>
<label for="female">
<input name="female" id="female" value="female" type="radio">
Female
</label>
For this html you can use this code in blade
{{ Form::label('male', 'Male') }}
{{ Form::radio('sex', 'male', array('id'=>'male','label'=>'female')) }}
{{ Form::label('female', 'Female') }}
{{ Form::radio('sex', 'female', array('id'=>'male','label'=>'female')) }}

how to change form field container div class?

I using symfony2.5. I change form field container div class.
generated form fields:
<div>
<label for="ddd" class="required">lname</label>
<input type="text" id="acme_demobundle_default_lname" name="acme_demobundle_default[lname]" required="required">
</div>
<div>
<label for="dddd" class="required">fname</label>
<input type="text" id="acme_demobundle_default_fname" name="acme_demobundle_default[fname]" required="required">
</div>
I add class to there are input`s container div.
any idea thanks
You can set attributes using the form builder inside your controller
$builder->add('lname', 'text', array('attr' => array('class'=>'something')))
If you have this in your form:
$builder->add('name')
In your template you should use the functions:
{{ form_label(form.name) }} {# access the label #}
{{ form_widget(form.name) }} {# access the input field #}
You can wrap that up with your div and style it however you want:
<div class="your-class">
{{ form_label(form.name) }}
{{ form_widget(form.name) }}
</div>
You can check more on How to Customize Form Rendering

LARAVEL styled password field with bootstrap

in this form i heve Form::password() and i can not styled or embeded class for that. for example this below class and style for Form::text can work correctly.
{{ Form::text('username', Input::old('username'), array('placeholder'=>'UserName', 'class'=>'form-control' ) ) }}
Generated HTML:
<input id="username" class="form-control" type="text" name="username" placeholder="username">
but for Form::password() do not work:
{{ Form::password('password', null, array('placeholder'=>'Password', 'class'=>'form-control' ) ) }}
Generated HTML:
<input id="password" type="password" value="" name="password">
This will work:
{{ Form::password('password', array('placeholder'=>'Password', 'class'=>'form-control' ) ) }}
You don't need the null as you cannot specify a default value for password fields.
You can also use a custom HTML macro that enables the syntax similar to your first example.
See my answer here:
How to pass value to Password field in Laravel
This problem occurred when the null value in the password.
{!! Form::password('password', old('password'), ['class' => 'form-control ', 'placeholder' => 'Enter Password']) !!}
Please Remove the old('password'):
{!! Form::password('password', ['class' => 'form-control', 'placeholder' => 'Enter Password']) !!}