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
Related
I am having a problem with modal window loading on staging server. Where my modal windows load on localhost (Apache) they fail to load content on staging (LiteSpeed). What is strange is that the modal opens and shows header, but no content. I get 503 error when I inspect elements.
Staging also doesn't load favicon. I suppose the problem is somewhere in configuration, but as I am just starting with Yii2, I don't know where to look anymore.
I have created the modal functionality as follows:
modal.js in web/js/modal.js
$(function(){
$(document).on('click', '.showModalButton', function(){
if ($('#modal').data('bs.modal').isShown) {
$('#modal').find('#modalContent')
.load($(this).attr('value'));
//dynamically set the header for the modal
document.getElementById('modalHeader').innerHTML = '<button type="button" class="close" ' +
'data-dismiss="modal" aria-label="Close">' +
'<span aria-hidden="true">×</span>' +
'</button> ' +
'<h4>' + $(this).attr('title') + '</h4>';
} else {
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
//dynamically set the header for the modal
document.getElementById('modalHeader').innerHTML = '<button type="button" class="close" ' +
'data-dismiss="modal" aria-label="Close">' +
'<span aria-hidden="true">×</span>' +
'</button> ' +
'<h4>' + $(this).attr('title') + '</h4>';
}
});
});
Layout set in views/layouts/main.php (excerpt)
</footer>
<?php
Modal::begin([
'headerOptions' => [
'id' => 'modalHeader',
],
//'footer' => 'Close',
'id' => 'modal',
'size' => 'modal-lg',
//keeps from closing modal with esc key or by clicking out of the modal.
// user must click cancel or X to close
'clientOptions' => [
'backdrop' => 'static',
'keyboard' => false
],
]);
echo "<div id='modalContent'></div>";
Modal::end();
?>
<?php $this->endBody() ?>
View for index action (excerpt)
<p>
<?= Html::a('Create FAQ',
false,
[
'class' => 'showModalButton btn btn-success',
'value' => '/index.html?r=faq/create',
'title' => 'Create FAQ',
]) ?>
</p>
When I press button modal opens,but doesn't load the form.
If I missed some important information, please ask if it can shed light to this issue.
The page loads all the assets and I get the 503 error only on staging server.
use yii\bootstrap\Modal;
in your Grid View
'panel' => [
'before' => Html::a('<i class="glyphicon glyphicon-plus">Open Modal</i>', ['#'], ['data-toggle' => 'modal', 'class' => 'btn btn-md btn-success', 'data-target' => '#showModal']),
'type' => GridView::TYPE_PRIMARY,
]
At the bottom add this
Modal::begin([
'id' => 'showModal',
'header' => '<center><h4 class="modal-title">Allocate Work </h4></center>',
'closeButton' => [
'label' => 'Close',
'class' => 'btn btn-danger btn-sm pull-right',
],
]);
echo Yii::$app->controller->renderPartial('allocation');
Modal::end();
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)
);
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.
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')) }}
<?php
$data = array(
'class' => "btn btn-primary btn-lg",
'name' => 'report'
);
echo '<span class="glyphicon glyphicon-exclamation-sign"></span> ';
echo form_submit($data, 'Report');
$data = array(
'class'=>"btn btn-primary btn-lg",
'name' => "search"
);
echo anchor("",'<span class="glyphicon glyphicon-search"></span> Search',$data);
echo form_close();
?>
I want to include <span class="glyphicon glyphicon-exclamation-sign"></span> on the form_submit. This span class is an image, I cant find a way to put it inside the button.
http://puu.sh/6UbE8.jpg
The second one "echo anchor", its second parameter has a span class which is also an image followed by a word "Search". This is exactly what I want the previous "form_submit" to be looks like. http://puu.sh/6UbFt.png
Use form_button instead of form_submit, and wrap your span around label.
$data = array(
'class' => "btn btn-primary btn-lg",
'name' => 'report'
);
echo form_button($data, '<span class="glyphicon glyphicon-exclamation-sign">Report</span>');
hope it will help
$data = array(
'name' => 'report',
'id' => 'report',
'value' => 'true',
'type' => 'submit',
'class' => 'btn btn-primary btn-lg'
);
echo form_button($data);
you can check http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html