本文整理汇总了PHP中yii\helpers\Html::button方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::button方法的具体用法?PHP Html::button怎么用?PHP Html::button使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::button方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$elements = $this->cart->elements;
if (empty($elements)) {
$cart = Html::tag('div', yii::t('cart', 'Your cart empty'), ['class' => 'pistol88-cart pistol88-empty-cart']);
} else {
$cart = Html::ul($elements, ['item' => function ($item, $index) {
return $this->_row($item);
}, 'class' => 'pistol88-cart-list']);
}
if (!empty($elements)) {
$bottomPanel = '';
if ($this->showTotal) {
$bottomPanel .= Html::tag('div', Yii::t('cart', 'Total') . ': ' . yii::$app->cart->cost . ' ' . yii::$app->cart->currency, ['class' => 'pistol88-cart-total-row']);
}
if ($this->offerUrl && $this->showOffer) {
$bottomPanel .= Html::a(yii::t('cart', 'Offer'), $this->offerUrl, ['class' => 'pistol88-cart-offer-button btn btn-success']);
}
if ($this->showTruncate) {
$bottomPanel .= TruncateButton::widget();
}
$cart .= Html::tag('div', $bottomPanel, ['class' => 'pistol88-cart-bottom-panel']);
}
$cart = Html::tag('div', $cart, ['class' => 'pistol88-cart']);
if ($this->type == self::TYPE_DROPDOWN) {
$button = Html::button($this->textButton . Html::tag('span', '', ["class" => "caret"]), ['class' => 'btn dropdown-toggle', 'id' => 'pistol88-cart-drop', 'type' => "button", 'data-toggle' => "dropdown", 'aria-haspopup' => 'true', 'aria-expanded' => "false"]);
$list = Html::tag('div', $cart, ['class' => 'dropdown-menu', 'aria-labelledby' => 'pistol88-cart-drop']);
$cart = Html::tag('div', $button . $list, ['class' => 'pistol88-cart-dropdown dropdown']);
}
return Html::tag('div', $cart, ['class' => 'pistol88-cart-block']);
}
示例2: run
/**
* @inheritdoc
*/
public function run()
{
$jsOptions = ['clientOptions' => $this->clientOptions];
$this->options['id'] = 'input-id';
if ($this->hasModel()) {
echo Html::activeInput('file', $this->model, $this->attribute, $this->options);
echo Html::img('#', ['id' => 'cropper-box']);
echo Html::button('Crop', ['id' => 'cropImage']);
$input_name = Html::getInputName($this->model, $this->attribute);
$input_id = Html::getInputId($this->model, $this->attribute);
echo Html::hiddenInput($input_name . '[file]', '', ['id' => $input_id . '_image']);
$jsOptions['model'] = $this->model;
$jsOptions['attribute'] = $this->attribute;
} else {
echo Html::fileInput($this->name, $this->value, $this->options);
echo Html::img('#', ['id' => 'cropper-box']);
echo Html::button('Crop', ['id' => 'cropImage']);
}
if ($this->uploadUrl) {
$this->uploadUrl = \Yii::getAlias($this->uploadUrl);
}
$jsOptions['uploadUrl'] = $this->uploadUrl;
$jsOptions['uploadCroppedUrl'] = $this->uploadCroppedUrl;
$jsOptions['changeUrl'] = $this->changeUrl;
$jsOptions['name'] = $this->name;
$jsOptions['aspectRatio'] = $this->aspectRatio;
$this->registerPlugin($jsOptions);
}
示例3: frame
/**
* Modal box for ajax requests
*
* @param $id
* @param $header
* @param $content
* @param null $footer
* @param null $style
* @return string
*/
public static function frame($id, $header, $content, $footer = null, $modalStyle = null, $modalDialogStyle = null)
{
if (is_null($footer)) {
$footer = Html::button('Bezárás', ['class' => 'btn btn-default', 'data-dismiss' => 'modal']);
}
if (!is_null($header)) {
$header = '<h4 class="modal-title">' . $header . '</h4>';
}
return '<div id="myModalBox' . $id . '" class="fade modal" role="dialog" tabindex="-1" style="' . $modalStyle . '" data-backdrop="static">
<div class="modal-dialog" style="' . $modalDialogStyle . '">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
' . $header . '
</div>
<div class="modal-body">
' . $content . '
</div>
<div class="modal-footer">
' . $footer . '
</div>
</div><!-- /.modal-content -->
</div>
</div>';
}
示例4: renderButtonAdd
protected function renderButtonAdd()
{
Html::addCssClass($this->buttonOptions, 'btn');
$this->buttonOptions = ArrayHelper::merge($this->buttonOptions, ['role' => 'area.add', 'data-tmpl' => $this->options['id']]);
$templateButtonAdding = strtr($this->templateButtonAdding, ['{button}' => Html::button('+', $this->buttonOptions), '{label}' => Html::tag('label', $this->label)]);
echo Html::tag('div', $templateButtonAdding, ['class' => 'form-group']);
}
示例5: run
/**
* @inheritdoc
*/
public function run()
{
if (!$this->visible) {
return "";
}
return Html::button($this->label, $this->options);
}
示例6: run
/**
* Renders the widget.
*/
public function run()
{
$this->registerClientScript();
$button = Html::button(FontAwesome::icon('picture-o') . ' ' . $this->buttonLabel, $this->buttonOptions);
$thumbs = '<ul class="kcf-thumbs" id="' . $this->getThumbsId() . '"></ul>';
echo Html::tag('div', strtr($this->template, ['{button}' => $button, '{thumbs}' => $thumbs]), ['class' => 'kcf-input-group']);
}
示例7: actionCreate
/**
* Creates a new ProyectoDistribucionPresupuestaria model.
* For ajax request will return json object
* and for non-ajax request if creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($proyecto)
{
$request = Yii::$app->request;
$model = new ProyectoDistribucionPresupuestaria();
$model->id_proyecto = $proyecto;
if ($request->isAjax) {
/*
* Process for ajax request
*/
Yii::$app->response->format = Response::FORMAT_JSON;
if ($request->isGet) {
return ['title' => "Create new ProyectoDistribucionPresupuestaria", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
} else {
if ($model->load($request->post()) && $model->save()) {
return ['forceReload' => 'true', 'title' => "Create new ProyectoDistribucionPresupuestaria", 'content' => '<span class="text-success">Create ProyectoDistribucionPresupuestaria success</span>', 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Create More', ['create'], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
} else {
return ['title' => "Create new ProyectoDistribucionPresupuestaria", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
}
}
} else {
/*
* Process for non-ajax request
*/
if ($model->load($request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
}
示例8: actionCreate
/**
* Creates a new UePartidaEntidad model.
* For ajax request will return json object
* and for non-ajax request if creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$request = Yii::$app->request;
$model = new UePartidaEntidad();
$ue = ArrayHelper::map(UnidadEjecutora::find()->asArray()->all(), 'id', 'nombre');
$tipo_entidad = ArrayHelper::map(TipoEntidad::find()->asArray()->all(), 'id', 'nombre');
if (!$request->isAjax) {
/*
* Process for ajax request
*/
Yii::$app->response->format = Response::FORMAT_JSON;
if ($request->isGet) {
return ['title' => "Create new UePartidaEntidad", 'content' => $this->renderAjax('create', ['model' => $model, 'ue' => $ue, 'tipo_entidad' => $tipo_entidad]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
} else {
if ($model->load($request->post()) && $model->save()) {
return ['forceReload' => '#crud-datatable-pjax', 'title' => "Create new UePartidaEntidad", 'content' => '<span class="text-success">Create UePartidaEntidad success</span>', 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Create More', ['create'], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
} else {
return ['title' => "Create new UePartidaEntidad", 'content' => $this->renderAjax('create', ['model' => $model, 'ue' => $ue, 'tipo_entidad' => $tipo_entidad]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
}
}
} else {
/*
* Process for non-ajax request
*/
if ($model->load($request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model, 'ue' => $ue, 'tipo_entidad' => $tipo_entidad]);
}
}
}
示例9: initializeModal
private function initializeModal(){
Modal::begin([
'id' => 'activity-modal',
'size' => $this->size,
'header' => '<h2>'. $this->modelTitle .'</h2>',
'footer' => Html::button('Close', ['class' => 'btn btn-info', 'data-dismiss' => 'modal']),
]);
Modal::end();
// Modal::begin([
// 'id' => 'activity-delete-modal',
// 'header' => '<h2>'. $this->deleteModelTitle .'</h2>',
// 'footer' => Html::button('Close', ['class' => 'btn btn-default', 'data-dismiss' => 'modal'])
// . PHP_EOL . Html::button('Delete', [
// 'class' => 'btn btn-primary btn-modal-save',
// 'id' => 'delete-role-model',
// 'data-id' => '',
// 'onClick' => new JsExpression('var id=$("#delete-role-model").attr("data-id");$.ajax({type:"'. $this->deleteVerb .'",url:"'.$this->deleteUrl.'",data:{id:id},success:function(){$.pjax.reload({container:"#'. $this->pjaxContainerId .'",timeout:2e3}),$("#activity-delete-modal").modal("hide")}});')
// ]),
// ]);
// echo 'Are You Sure To Delete This Item';
// Modal::end();
}
示例10: initDefaultButtons
/**
* @inheritdoc
*/
protected function initDefaultButtons()
{
foreach ($this->languages as $lang_id => $lang) {
$name = "update-{$lang_id}";
$this->template .= ' {' . $name . '}';
if (!isset($this->buttons[$name])) {
$this->buttons[$name] = function () use($lang, $lang_id) {
/** @var \lav45\translate\TranslatedTrait $model */
$model = func_get_arg(1);
$key = func_get_arg(2);
$params = is_array($key) ? $key : ['id' => (string) $key];
$params[$this->languageAttribute] = $lang_id;
$params[0] = $this->controller ? $this->controller . '/update' : 'update';
$url = Url::toRoute($params);
$color = $model->hasTranslate($lang_id) ? 'info' : 'default';
$options = ['class' => "btn btn-xs btn-{$color}", 'title' => "Edit {$lang} version", 'data-pjax' => '0'];
if ($this->ajax) {
$options['data-href'] = $url;
return Html::button('<span class="glyphicon glyphicon-pencil"></span> ' . $lang, $options);
} else {
return Html::a('<span class="glyphicon glyphicon-pencil"></span> ' . $lang, $url, $options);
}
};
}
}
}
示例11: tombolCreate
function tombolCreate()
{
if (getPermission()) {
if (getPermission()->BTN_CREATE == 1) {
$title1 = Yii::t('app', 'NEW PO');
$options1 = ['id' => 'po-create', 'data-toggle' => "modal", 'data-target' => "#new-po", 'class' => 'btn btn-warning btn-sm'];
$icon1 = '<span class="fa fa-plus fa-lg"></span>';
$label1 = $icon1 . ' ' . $title1;
$content = Html::button($label1, $options1);
return $content;
} else {
$title1 = Yii::t('app', 'CREATE NEW PO');
$options1 = ['id' => 'po-create', 'class' => 'btn btn-warning btn-sm', 'data-confirm' => 'Permission Failed !'];
$icon1 = '<span class="fa fa-plus fa-lg"></span>';
$label1 = $icon1 . ' ' . $title1;
$content = Html::button($label1, $options1);
return $content;
}
} else {
$title1 = Yii::t('app', 'CREATE NEW PO');
$options1 = ['id' => 'ro-create', 'class' => 'btn btn-warning btn-sm', 'data-confirm' => 'Permission Failed !'];
$icon1 = '<span class="fa fa-plus fa-lg"></span>';
$label1 = $icon1 . ' ' . $title1;
$content = Html::button($label1, $options1);
return $content;
}
}
示例12: run
public function run()
{
if ($this->hasModel()) {
$replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
$replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
}
$replace['{button}'] = Html::button($this->buttonName, $this->buttonOptions);
$replace['{preview}'] = Html::a($this->previewButtonName, "#" . $this->previewButtonOptions['id'] . '_popup', $this->previewButtonOptions) . '
<div id="' . $this->previewButtonOptions['id'] . '_popup" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h5 class="modal-title"><i class="fa fa-picture-o"></i> Preview</h5>
</div>
<div class="modal-body has-padding">
<img width="100%" src="' . $this->suffix . $this->model->{$this->attribute} . '">
</div>
<div class="modal-footer">
<button class="btn btn-warning" data-dismiss="modal"><i class="fa fa-times"></i> Close</button>
</div>
</div>
</div>
</div>';
echo strtr($this->template, $replace);
AssetsCallBack::register($this->getView());
if (!empty($this->multiple)) {
$this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(files, id){ var _f = []; for (var i in files) { _f.push(files[i].url); } \$('#' + id).val(_f.join(', ')); return true;}); \$('#" . $this->buttonOptions['id'] . "').click(function(){mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});");
} else {
$this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\r\n\t \$('#' + id).val(file.url.replace('" . $this->suffix . "', ''));\r\n\t \$('#' + id + '_preview_popup .modal-body').html('<img width=\"100%\" src=\"' + file.url + '\">'); return true;}); \$('#" . $this->buttonOptions['id'] . "').click(function(){mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});");
}
}
示例13: run
public function run()
{
parent::run();
$this->registerAssets();
$view = $this->getView();
$id = $this->getId();
$output = '';
$output .= Html::input('hidden', $this->inputName, null, ['id' => $this->inputId]);
$output .= Html::beginTag('div', ['class' => 'row']);
$output .= Html::beginTag('div', ['class' => 'col-xs-12']);
$output .= Html::tag('canvas', '', ['class' => ['signature-input-canvas'], 'style' => ['border' => '1px solid black', 'width' => '100%']]);
$output .= Html::endTag('div');
$output .= Html::beginTag('div', ['class' => 'col-xs-12']);
$output .= Html::button(\Yii::t('app', 'Clear'), ['class' => ['col-xs-12', 'btn', 'btn-default'], 'id' => $id . '-clear']);
$output .= Html::endTag('div');
$output .= Html::endTag('div');
$view->registerJs(<<<JS
\$(function(){
var canvas = \$("#{$id} .signature-input-canvas")[0];
var signaturePad = new SignaturePad(canvas);
signaturePad.onEnd = function(){
var result = signaturePad.toDataURL();
\$('#{$this->inputId}').val(result);
};
\$('#{$id}-clear').on('click', function(){
\$('#{$this->inputId}').val('');
signaturePad.clear();
});
})
JS
);
return Html::tag('div', $output, ['id' => $id, 'class' => ['signature-input']]);
}
示例14: renderDataCellContent
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
$result = '';
if ($this->defaultItems) {
$this->items = [['label' => Yii::t('yii', 'Update'), 'url' => ['update']], ['label' => Yii::t('yii', 'View'), 'url' => ['view']], ['label' => Yii::t('yii', 'Delete'), 'url' => ['delete'], 'linkOptions' => ['data-method' => 'post']]];
}
$firstKey = current(array_keys($this->items));
$mainBtn = $this->items[$firstKey];
$result .= Html::a($mainBtn['label'], array_merge($mainBtn['url'], [$model->primaryKey()[0] => $key]), array_merge(['class' => 'btn btn-default btn-sm'], isset($mainBtn['linkOptions']) ? $mainBtn['linkOptions'] : []));
if (count($this->items) != 1) {
$result .= Html::button(Html::tag('span', '', ['class' => 'caret']) . Html::tag('span', 'Toggle Dropdown', ['class' => 'sr-only']), ['class' => 'btn btn-default btn-sm dropdown-toggle', 'data-toggle' => 'dropdown', 'aria-haspopup' => 'true', 'aria-expanded' => 'false']);
$items = '';
$firstElement = true;
foreach ($this->items as $itemIndex => $item) {
if (isset($this->visibleButtons[$itemIndex])) {
$isVisible = $this->visibleButtons[$itemIndex] instanceof \Closure ? call_user_func($this->visibleButtons[$itemIndex], $model, $key, $index) : $this->visibleButtons[$itemIndex];
} else {
$isVisible = true;
}
if ($isVisible) {
if ($firstElement) {
$firstElement = false;
continue;
}
$items .= Html::tag('li', Html::a($item['label'], array_merge($item['url'], [$model->primaryKey()[0] => $key]), isset($item['linkOptions']) ? $item['linkOptions'] : []), isset($item['options']) ? $item['options'] : []);
}
}
$result .= Html::tag('ul', $items, ['class' => 'dropdown-menu dropdown-menu-right']);
}
return Html::tag('div', $result, ['class' => 'btn-group pull-right', 'style' => 'display: flex']);
}
示例15: renderToggleButton
/**
* Рисуем кнопки отображения пунктов меню верхней и боковой панелей при узком экране
*
* @return string the rendering toggle buttons.
*/
protected function renderToggleButton()
{
$bar = Html::tag('span', '', ['class' => 'icon-bar']);
$screenReader = "<span class=\"sr-only\">{$this->screenReaderToggleText}</span>";
$navBarButton = Html::button("{$screenReader}\n{$bar}\n{$bar}\n{$bar}", ['class' => 'navbar-toggle', 'data-toggle' => 'collapse', 'data-target' => "#{$this->containerOptions['id']}"]);
$sidebarButton = Html::button("{$screenReader}\n{$bar}\n{$bar}\n{$bar}", ['class' => 'navbar-toggle menu-toggler pull-left', 'data-target' => "#sidebar"]);
return $navBarButton . $sidebarButton;
}