Laravel code Issue - php

Someone Help me for convert html code into laravel
HTML code look like
<td><button class="btn red" type="button"><i class="icon-remove"></i> Delete</button></td>
i am try following but it is not work properly
{{HTML::linkRoute('users.edit','Edit',$value->id,['class'=>'btn green'])}}

If you are wanting a button use the following;
{{ Form::button('Edit', array('type' => 'button', 'class' => 'btn green', 'onclick' => 'window.location="' . route('users.edit', $value->id) . '"')); }}

this may work for you
{{ link_to_route('users.edit', 'Edit',$value->id,array('class' => 'btn green')) }}

Related

Yii2 Button url to folder

I want to create a button which opens a pdf. This pdf is in another folder, but I can't reach this folder. Can somebody help me, I'm quite new to this.
Here is my Button:
$button = Html::a('Geef document weer', ['/uploads/documenten/' . $model->documents[0]->location . '/' . $model->documents[0]->file . $model->documents[0]->format], ['class' => 'btn btn-primary btn-xs', 'target' => '_blank']);
Don't use hash notation but specify the link and in 'yourPath' set the proper value
$button = Html::a('Geef document weer',
'yourPath/uploads/documenten/' . $model->documents[0]->location . '/' . $model->documents[0]->file . $model->documents[0]->format,
['class' => 'btn btn-primary btn-xs', 'target' => '_blank']);
or use #web alias
$button = Html::a('Geef document weer',
Url::to('#web/uploads/documenten/') . $model->documents[0]->location . '/' . $model->documents[0]->file . $model->documents[0]->format,
['class' => 'btn btn-primary btn-xs', 'target' => '_blank']);
Write out the link without using the html helpers

How to put glyphicon inside cakephp submit form?

The code:
<?php echo $this->Form->submit('<i class="glyphicon glyphicon-arrow-right"></i>', array('class' => array('btn btn-danger')), array('escape' => false)); ?>
Instead of glyphicon it shows just text:
<i class="glyphicon glyphicon-arrow-right"></i>
How to solve this?
As per the docs, you can't use escape with Submit- you have to use Button instead and specify that it's a submit button:
echo $this->Form->button('<i class="glyphicon glyphicon-arrow-right"></i>', array(
'type' => 'submit',
'class' => 'btn btn-danger',
'escape' => false
));
Form->submit() should take two options, a caption and an array of options. You are passing it the caption plus two arrays. Also I don't think in this case you need to wrap these options within sub-arrays.
Try this:
echo $this->Form->submit('<i class="glyphicon glyphicon-arrow-right"></i>',
array('class' => 'btn btn-danger', 'escape' => false)
);

yii2: How to work with font awesome icons?

I have this HTML link tag that I need to generate using yii\helpers\Html
<i class="fa fa-fw fa-user"></i> Sign Up
I am able to do it using method a() but I do not know how to include the font awesome class. Here is the code that I already have using a() method
<?= Html::a('Sign Up',['site/signup'], ['class' => 'btn btn-black', 'title' => 'Sign Up']) ?>
I am using bootstrap for my CSS. Any help would be appreciated.
It's simple
<?= Html::a('<i class="fa fa-fw fa-user"></i> Sign Up',['site/signup'], ['class' => 'btn btn-black', 'title' => 'Sign Up']) ?>
Following code generate your desired HTML.
<?= Html::a(Html::tag('i', '', ['class' => 'fa fa-fw fa-user']) . ' Sign Up ', ['site/signup'], ['class' => 'btn btn-black', 'title' => 'Sign Up']) ?>
You can also use yii2-icons, see: https://github.com/kartik-v/yii2-icons
At first you have to install the extension:
composer require kartik-v/yii2-icons "#dev"
Then you can display the icons e.g. in the following way:
use kartik\icons\Icon;
...
Icon::show('trash', ['title' => 'delete'])
Icon::show('calendar', ['class'=>'fa-2x'])
You can find more examples on this demopage: http://demos.krajee.com/icons

How to include a button within a form that does not act as the Submit button

I have a form that I would like a user to fill out with some basic information. However, before submitting the info, I want to include a button I am using to activate Stripe to request payment.
I have tried this so far, however, this button before the submission button is acting as the submit button.
Here is some code:
{{ Form::open(array('route' => 'fans.store')) }}
{{ Form::label('name', 'Name:') }}
{{ Form::text('name', null, array(
'class' => 'input',
));}}
{{ Form::label('email', 'Email:') }}
{{ Form::text('email', null, array(
'class' => 'input',
));}}
<div class="button_row">
<button id="customButton" class="button">Purchase</button>
</div>
<div class="button_row">
{{Form::submit('Submit', ['class' => 'button'])}}
</div>
{{Form::close()}}
Any work arounds? The syntax is blade php (I'm using Laravel 4). Thank you.
Try the following:
{{ Form::button('purchase', 'Purchase with Stripe', array( 'id' => 'purchase', 'onclick'=>'myFunction()')) }}
That creates a purchase button,
labeled "Purchase with Stripe"
Calls myFunction() that launches stripe
<button type="button">
See: http://www.w3schools.com/tags/att_button_type.asp

How can i add a icon to submit button Yii?

Html button is
<button class="btn" type="submit"><i class="icon-search"></i> Go</button>
I changed it into Yii as
<?php
echo CHtml::submitButton('Go', array('id' => 'btSubmit',
'class' => 'btn',
'name' => 'files'
));
?>
How can i add to button
This will work
echo CHtml::tag('button', array(
'name'=>'btnSubmit',
'type'=>'submit'
), '<i class="icon-search"></i> Go');
will generate
<button name="btnSubmit" type="submit"><i class="icon-search"></i> Go</button>
According to the yii source code the CHtml::tag method requires a third parameter to submit internal content. The CHtml::button method does not pass this through, so you can't add internal HTML.
Using the tag method directly should work however:
echo CHtml::tag('button',[
'id'=>'btsubmit','class'=>'btn','name'=>'files','type'=>'submit'
],'<i class="icon-search"></i> Go');
<?php echo CHtml::submitButton(
CHtml::tag('i', array('class' => 'icon-search')) . ' Go',
array('id' => 'btSubmit',
'class' => 'btn',
'name' => 'files')
);
?>
Use CHtml::tag('i', array('class' => 'icon-search')) . ' Go' instead of 'Go' in your code.

Categories