本文整理汇总了PHP中kartik\helpers\Html::beginTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::beginTag方法的具体用法?PHP Html::beginTag怎么用?PHP Html::beginTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kartik\helpers\Html
的用法示例。
在下文中一共展示了Html::beginTag方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run()
{
parent::run();
$wid = $this->options['id'];
echo Html::activeHiddenInput($this->model, $this->attribute);
echo Html::beginTag('div', ['id' => $wid . '-buttons', 'class' => 'input-group btn-group']);
$items = PublishBehavior::getPublishedOptions();
$colors = PublishBehavior::getPublishedColors();
foreach ($items as $key => $item) {
echo Html::button($item, ['data' => ['value' => $key], 'class' => $key == $this->model->{$this->attribute} ? 'btn btn-' . $colors[$key] . ' active' : 'btn btn-default']);
}
echo Html::endTag('div');
$js_colors = Json::encode($colors);
$js = <<<JS
\$('#{$wid}-buttons').find('button').each(function(){
\$(this).on('click',function(){
\$('#{$wid}-buttons').find('button').each(function(){
\$(this).removeClass('btn-danger btn-warning btn-success btn-info active');
\$(this).addClass('btn-default');
});
var color={$js_colors};
\$(this).removeClass('btn-default');
\$(this).addClass('btn-'+color[\$(this).data('value')]+' active');
\$('#{$wid}').val(\$(this).data('value'))
});
});
JS;
$this->view->registerJs($js);
}
示例2: run
public function run()
{
$object = Object::getForClass(\app\models\Form::className());
$groups = PropertyGroup::getForModel($object->id, $this->formId);
$view = !empty($this->model->form_view) ? $this->model->form_view : 'form';
$successView = !empty($this->model->form_success_view) ? $this->model->form_success_view : 'success';
if (!$this->isModal) {
echo Html::beginTag('div', ['id' => 'form-info-' . $this->id, 'style' => 'display: none;']);
echo $this->render($successView);
echo '</div>';
}
echo $this->render($view, ['id' => $this->id, 'model' => $this->model, 'groups' => $groups, 'options' => $this->options]);
if ($this->isModal) {
Modal::end();
Modal::begin(['id' => 'modal-form-info-' . $this->id, 'size' => Modal::SIZE_SMALL, 'header' => $this->statusHeaderName ? $this->statusHeaderName : $this->model->name . ' ' . \Yii::t('app', 'status')]);
echo $this->render($successView);
Modal::end();
}
}
示例3: renderAlertBlock
/**
* Initializes and renders alert container block
*/
protected function renderAlertBlock()
{
$session = Yii::$app->session;
$flashes = $session->getAllFlashes();
if (count($flashes) === 0) {
Html::addCssStyle($this->alertContainerOptions, 'display:none;');
}
$out = Html::beginTag('div', $this->alertContainerOptions);
foreach ($flashes as $type => $message) {
$class = ArrayHelper::getValue($this->alertMessageSettings, $type, 'alert alert-' . $type);
$options = ArrayHelper::getValue($this->alertWidgetOptions, 'options', []);
Html::addCssClass($options, $class);
$this->alertWidgetOptions['body'] = $message;
$this->alertWidgetOptions['options'] = $options;
$out .= "\n" . Alert::widget($this->alertWidgetOptions);
$session->removeFlash($type);
}
$out .= "\n</div>";
return $out;
}
示例4: foreach
</header>
<div class="widget-body">
<?php
foreach ($groups as $group) {
?>
<?php
$properties = Property::getForGroupId($group->id);
?>
<?php
foreach ($properties as $property) {
?>
<?php
if ($propertyValues = $review->submission->getPropertyValuesByPropertyId($property->id)) {
?>
<?php
echo Html::beginTag('div', ['class' => 'col-md-8']);
?>
<?php
echo $property->handler('form', $review->submission->abstractModel, $propertyValues, 'backend_render_view');
?>
<?php
echo Html::endTag('div');
?>
<?php
}
?>
<?php
}
?>
<?php
}
示例5:
<?php
use kartik\helpers\Html;
echo Html::beginTag('div', $options);
?>
<header>
<h2><?php
echo $title;
?>
</h2>
<?php
echo $header_append;
?>
</header>
<div>
<!-- widget edit box -->
<div class="jarviswidget-editbox">
<!-- This area used as dropdown edit box -->
<input class="form-control" type="text">
</div><!-- end widget edit box -->
<!-- widget content -->
<div class="widget-body">
<?php
echo $content;
?>
<?php
示例6: function
<?php
echo $form->field($model, 'file')->fileInput();
?>
</div>
</div>
<div class="form-group row">
<div class="col-md-12">
<fieldset>
<legend>
<?php
echo Yii::t('app', 'Add property groups to each new object: ');
?>
</legend>
<?php
echo $form->field($model, 'addPropertyGroups')->checkboxList(\yii\helpers\ArrayHelper::map(\app\models\PropertyGroup::getForObjectId($object->id), 'id', 'name'), ['item' => function ($index, $label, $name, $checked, $value) {
$line = Html::beginTag('div', ['class' => 'checkbox']);
$line .= Html::checkbox($name, $checked, ['value' => $value, 'label' => Html::encode($label)]);
$line .= '</div>';
return $line;
}])->label('');
?>
</fieldset>
</div>
</div>
<?php
}
?>
<?php
if (!$importMode) {
?>
示例7: array2table
/**
* Convert a PHP array to HTML table.
*
* Example:
*
* ~~~
* $data = [
* ['id' => 1, 'name' => 'John', 'birthday' => '01-Jul-1976', 'commission'=>'4,500.50', 'active' => true],
* [2, 'Scott', '26-Feb-1980', '1,300.40', true],
* [3, 'Mary', '1990-02-10', null, false],
* [4, 'Lisa', '17-Dec-1982', '-900.34', true],
* ];
* echo Enum::array2table($data);
* ~~~
*
* @param array $array the associative array to be converted
* @param boolean $transpose whether to show keys as rows instead of columns. This parameter should be used only
* for a single dimensional associative array. If used for a multidimensional array, the sub array will be imploded
* as text.
* @param boolean $recursive whether to recursively generate tables for multi-dimensional arrays
* @param boolean $typeHint whether to show the data type as a hint
* @param string $null the content to display for blank cells
* @param array $tableOptions the HTML attributes for the table
* @param array $keyOptions the HTML attributes for the array key
* @param array $valueOptions the HTML attributes for the array value
*
* @return string|boolean
*/
public static function array2table($array, $transpose = false, $recursive = false, $typeHint = true, $tableOptions = ['class' => 'table table-bordered table-striped'], $keyOptions = [], $valueOptions = ['style' => 'cursor: default; border-bottom: 1px #aaa dashed;'], $null = '<span class="not-set">(not set)</span>')
{
// Sanity check
if (empty($array) || !is_array($array)) {
return false;
}
// Start the table
$table = Html::beginTag('table', $tableOptions) . "\n";
// The header
$table .= "\t<tr>";
if ($transpose) {
foreach ($array as $key => $value) {
if ($typeHint) {
$valueOptions['title'] = self::getType(strtoupper($value));
}
if (is_array($value)) {
$value = '<pre>' . print_r($value, true) . '</pre>';
} else {
$value = Html::tag('span', $value, $valueOptions);
}
$table .= "\t\t<th>" . Html::tag('span', $key, $keyOptions) . "</th>" . "<td>" . $value . "</td>\n\t</tr>\n";
}
$table .= "</table>";
return $table;
}
if (!isset($array[0]) || !is_array($array[0])) {
$array = array($array);
}
// Take the keys from the first row as the headings
foreach (array_keys($array[0]) as $heading) {
$table .= '<th>' . Html::tag('span', $heading, $keyOptions) . '</th>';
}
$table .= "</tr>\n";
// The body
foreach ($array as $row) {
$table .= "\t<tr>";
foreach ($row as $cell) {
$table .= '<td>';
// Cast objects
if (is_object($cell)) {
$cell = (array) $cell;
}
if ($recursive === true && is_array($cell) && !empty($cell)) {
// Recursive mode
$table .= "\n" . static::array2table($cell, true, true) . "\n";
} else {
if (!is_null($cell) && is_bool($cell)) {
$val = $cell ? 'true' : 'false';
$type = 'boolean';
} else {
$chk = strlen($cell) > 0;
$type = $chk ? self::getType($cell) : 'NULL';
$val = $chk ? htmlspecialchars((string) $cell) : $null;
}
if ($typeHint) {
$valueOptions['title'] = $type;
}
$table .= Html::tag('span', $val, $valueOptions);
}
$table .= '</td>';
}
$table .= "</tr>\n";
}
$table .= '</table>';
return $table;
}
示例8: foreach
<div class="properties-widget widget-<?php
echo $widget_id;
?>
" itemprop="propertiesList" itemscope itemtype="http://schema.org/ItemList">
<?php
if (!empty($object_property_groups)) {
foreach ($object_property_groups as $i => $opg) {
if ($opg->group->is_internal) {
continue;
}
$options = ['id' => 'pg-' . $opg->group->id, 'class' => 'object-property-group'];
if ($i == 0) {
\kartik\helpers\Html::addCssClass($options, 'active');
}
echo \kartik\helpers\Html::beginTag('div', $options);
/** @var \app\models\Property[] $properties */
$properties = app\models\Property::getForGroupId($opg->group->id);
foreach ($properties as $prop) {
if ($property_values = $model->getPropertyValuesByPropertyId($prop->id)) {
echo $prop->handler($form, $model->getAbstractModel(), $property_values, 'frontend_render_view');
}
}
echo "</div>";
}
} else {
echo '<!-- Empty properties -->';
}
?>
</div> <!-- /properties-widget -->
示例9: renderAttribute
/**
* Renders a single attribute.
*
* @param array $attribute the specification of the attribute to be rendered.
* @param int $index the zero-based index of the attribute in the [[attributes]] array
*
* @return string the rendering result
*/
protected function renderAttribute($attribute, $index)
{
$rowOptions = ArrayHelper::getValue($attribute, 'rowOptions', $this->rowOptions);
$labelColOptions = ArrayHelper::getValue($attribute, 'labelColOptions', $this->labelColOptions);
$valueColOptions = ArrayHelper::getValue($attribute, 'valueColOptions', $this->valueColOptions);
if (ArrayHelper::getValue($attribute, 'group', false) === true) {
$groupOptions = ArrayHelper::getValue($attribute, 'groupOptions', []);
$label = ArrayHelper::getValue($attribute, 'label', '');
if (empty($groupOptions['colspan'])) {
$groupOptions['colspan'] = 2;
}
return Html::tag('tr', Html::tag('th', $label, $groupOptions), $rowOptions);
}
if ($this->hideIfEmpty === true && empty($attribute['value'])) {
Html::addCssClass($rowOptions, 'kv-view-hidden');
}
if (ArrayHelper::getValue($attribute, 'type', 'text') === self::INPUT_HIDDEN) {
Html::addCssClass($rowOptions, 'kv-edit-hidden');
}
$dispAttr = $this->formatter->format($attribute['value'], $attribute['format']);
Html::addCssClass($this->viewAttributeContainer, 'kv-attribute');
Html::addCssClass($this->editAttributeContainer, 'kv-form-attribute');
$output = Html::tag('div', $dispAttr, $this->viewAttributeContainer) . "\n";
if ($this->enableEditMode) {
$editInput = !empty($attribute['displayOnly']) && $attribute['displayOnly'] ? $dispAttr : $this->renderFormAttribute($attribute);
$output .= Html::tag('div', $editInput, $this->editAttributeContainer);
}
return Html::beginTag('tr', $rowOptions) . "\n" . Html::beginTag('th', $labelColOptions) . $attribute['label'] . "</th>\n" . Html::beginTag('td', $valueColOptions) . $output . "</td>\n</tr>";
}
示例10: foreach
$image = $model->getImage();
// $sizes = $image->getSizesWhen('x300');
// echo Html::img($image->getUrl('x300'),['class' => 'center-block img-responsive','width'=>$sizes['width'], 'height'=>$sizes['height']]);
echo Html::img($image->getUrl('x900'), ['class' => 'center-block img-responsive', 'width' => '100%']);
}
?>
</div>
</div>
<div class="news-view well">
<h1 class="text-center"><?php
echo Html::encode($this->title);
?>
</h1>
<?php
echo Html::tag('div', $model->content, ['class' => '']);
?>
<div class="news-images-block">
<?php
if ($images[0]['urlAlias'] != 'placeHolder') {
foreach ($images as $img) {
echo Html::beginTag('div', ['class' => 'news-images-box', 'style' => 'margin-bottom:20px']);
if (!$img->isMain) {
echo Html::a(Html::img($img->getUrl('x500'), ['class' => 'center-block img-responsive']), $img->getUrl(''), ['class' => 'lightbox']);
}
echo Html::endTag('div');
}
}
?>
</div>
</div>
示例11:
<?php
use kartik\helpers\Html;
use yii\bootstrap\ActiveForm;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$form = ActiveForm::begin(['id' => 'user-form', 'layout' => 'inline', 'method' => 'POST']);
$ka = $rowNr;
echo Html::beginTag('table');
echo Html::beginTag('tr', ['data-row' => '1']);
echo Html::tag('td', $form->field($auth, '[' . $ka . ']type')->dropDownList($auth->getTypeArr(), ['style' => 'width:120px;', 'prompt' => '--']));
echo Html::tag('td', $form->field($auth, '[' . $ka . ']allowFrom')->textInput(['style' => 'width:120px;']));
echo Html::tag('td', $form->field($auth, '[' . $ka . ']allowTo')->textInput(['style' => 'width:120px;']));
echo Html::endTag('tr');
echo Html::endTag('table');
$form->end();
示例12: init
public function init()
{
foreach ($this->attributes as $attribute) {
static::validateAttribute($attribute);
}
Html::addCssClass($this->options, 'detail-view');
$this->validateDisplay();
if ($this->bootstrap) {
Html::addCssClass($this->options, 'table');
if ($this->hover) {
Html::addCssClass($this->options, 'table-hover');
}
if ($this->bordered) {
Html::addCssClass($this->options, 'table-bordered');
}
if ($this->striped) {
Html::addCssClass($this->options, 'table-striped');
}
if ($this->condensed) {
Html::addCssClass($this->options, 'table-condensed');
}
}
Html::addCssStyle($this->labelColOptions, "text-align:{$this->hAlign};vertical-align:{$this->vAlign};");
parent::init();
if (empty($this->container['id'])) {
$this->container['id'] = $this->getId();
}
$this->initI18N();
$this->template = strtr($this->template, ['<th>' => Html::beginTag('th', $this->labelColOptions), '<td>' => Html::beginTag('td', $this->valueColOptions)]);
Html::addCssClass($this->formOptions, 'kv-detail-view-form');
$this->formOptions['fieldConfig']['template'] = "{input}\n{hint}\n{error}";
$this->_form = ActiveForm::begin($this->formOptions);
$this->registerAssets();
}
示例13: Auth
<tr>
<th style="width:200px;">Type</th>
<th style="width:100px;">IP Von</th>
<th style="width:170px;">IP Bis</th>
<th style="width:170px;"></th>
</tr>
</thead>
<tbody>
<?php
if ($model->isNewRecord === TRUE) {
$model->auth = [0];
}
// Anzeigen der gespeicherten Logins -------------------
foreach ($model->auth as $i => $authData) {
$auth = new Auth($authData);
echo Html::beginTag('tr');
echo Html::tag('td', $form->field($auth, '[' . $i . ']type')->dropDownList($auth->getTypeArr(), ['style' => 'width:120px;', 'prompt' => '--']));
echo Html::tag('td', $form->field($auth, '[' . $i . ']allowFrom')->textInput(['style' => 'width:120px;']));
echo Html::tag('td', $form->field($auth, '[' . $i . ']allowTo')->textInput(['style' => 'width:120px;']));
echo Html::endTag('tr');
#$ka++;
}
?>
</tbody>
</table>
</div>
</div>
<?php
$js = <<<JS
var ka = "{$ka}";\t
\$(document).on('click','#btn-newauth',function(){