本文整理汇总了PHP中app\components\Helper::getModelMap方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::getModelMap方法的具体用法?PHP Helper::getModelMap怎么用?PHP Helper::getModelMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\components\Helper
的用法示例。
在下文中一共展示了Helper::getModelMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$object = app\models\Object::getForClass($this->model->className());
/** @var \app\modules\shop\models\AddonCategory $addonCategories */
$addonCategories = app\components\Helper::getModelMap(AddonCategory::className(), 'id', 'name');
/** @var app\modules\shop\models\Addon $bindedAddons */
$bindedAddons = $this->model->bindedAddons;
$addAddonModel = new AddAddonModel();
return $this->render('addons-widget', ['object' => $object, 'addonCategories' => $addonCategories, 'bindedAddons' => $bindedAddons, 'model' => $this->model, 'form' => $this->form, 'addAddonModel' => $addAddonModel]);
}
示例2: actionIndex
/**
* Lists all Order models.
* @return mixed
*/
public function actionIndex()
{
$searchModelConfig = ['defaultOrder' => ['id' => SORT_DESC], 'model' => Order::className(), 'relations' => ['user' => ['username']], 'partialMatchAttributes' => ['start_date', 'end_date', 'user_username'], 'additionalConditions' => []];
if (intval($this->module->showDeletedOrders) === 0) {
$searchModelConfig['additionalConditions'] = [['is_deleted' => 0]];
}
/** @var SearchModel $searchModel */
$searchModel = new SearchModel($searchModelConfig);
if (intval($this->module->defaultOrderStageFilterBackend) > 0) {
$searchModel->order_stage_id = intval($this->module->defaultOrderStageFilterBackend);
}
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', ['dataProvider' => $dataProvider, 'managers' => $this->getManagersList(), 'orderStages' => Helper::getModelMap(OrderStage::className(), 'id', 'name_short'), 'paymentTypes' => Helper::getModelMap(PaymentType::className(), 'id', 'name'), 'searchModel' => $searchModel, 'shippingOptions' => Helper::getModelMap(ShippingOption::className(), 'id', 'name')]);
}
示例3:
?>
">
<?php
BackendWidget::begin(['title' => Yii::t('app', 'Category'), 'icon' => 'tree', 'footer' => $this->blocks['submit']]);
?>
<?php
echo $form->field($model, 'active')->widget(\kartik\switchinput\SwitchInput::className());
?>
<?php
if ($model->parent_id == 0) {
?>
<?php
echo $form->field($model, 'category_group_id')->dropDownList(\app\components\Helper::getModelMap(\app\modules\shop\models\CategoryGroup::className(), 'id', 'name'));
?>
<?php
}
?>
<?php
echo $form->field($model, 'name');
?>
<?php
echo $form->field($model, 'title', ['copyFrom' => ["#category-name", "#category-h1", "#category-breadcrumbs_label"]]);
?>
<?php
echo $form->field(app\models\ViewObject::getByModel($model, true), 'view_id')->dropDownList(app\models\View::getAllAsArray());
示例4:
?>
</th>
<td>
<?php
echo $orderIsImmutable ? Html::encode($model->stage->name_short) : Editable::widget(['attribute' => 'order_stage_id', 'data' => \app\components\Helper::getModelMap(\app\modules\shop\models\OrderStage::className(), 'id', 'name_short'), 'displayValue' => $model->stage !== null ? Html::tag('span', $model->stage->name_short) : Html::tag('em', Yii::t('yii', '(not set)')), 'formOptions' => ['action' => ['update-stage', 'id' => $model->id]], 'inputType' => Editable::INPUT_DROPDOWN_LIST, 'model' => $model]);
?>
</td>
</tr>
<tr>
<th><?php
echo $model->getAttributeLabel('payment_type_id');
?>
</th>
<td>
<?php
echo $orderIsImmutable ? null !== $model->paymentType ? Html::encode($model->paymentType->name) : Html::tag('em', Yii::t('yii', '(not set)')) : Editable::widget(['attribute' => 'payment_type_id', 'data' => \app\components\Helper::getModelMap(\app\modules\shop\models\PaymentType::className(), 'id', 'name'), 'displayValue' => $model->paymentType !== null ? Html::tag('span', $model->paymentType->name) : Html::tag('em', Yii::t('yii', '(not set)')), 'formOptions' => ['action' => ['update-payment-type', 'id' => $model->id]], 'inputType' => Editable::INPUT_DROPDOWN_LIST, 'model' => $model]);
?>
</td>
</tr>
<?php
foreach ($model->abstractModel->attributes as $name => $attribute) {
?>
<tr>
<th><?php
echo $model->abstractModel->getAttributeLabel($name);
?>
</th>
<td>
<button data-toggle="modal" data-target="#custom-fields-modal" class="kv-editable-value kv-editable-link">
<?php
echo !empty($attribute) ? Html::encode($attribute) : Html::tag('em', Yii::t('yii', '(not set)'));
示例5: function
* @var \app\models\Form $searchModel
*/
use kartik\dynagrid\DynaGrid;
use kartik\helpers\Html;
$this->title = Yii::t('app', 'Currencies');
$this->params['breadcrumbs'][] = $this->title;
?>
<?php
echo app\widgets\Alert::widget(['id' => 'alert']);
$this->beginBlock('add-button');
echo \yii\helpers\Html::a(\kartik\icons\Icon::show('plus') . ' ' . Yii::t('app', 'Add'), ['edit', 'returnUrl' => \app\backend\components\Helper::getReturnUrl()], ['class' => 'btn btn-success']);
echo \app\backend\widgets\RemoveAllButton::widget(['url' => 'remove-all', 'gridSelector' => '.grid-view', 'htmlOptions' => ['class' => 'btn btn-danger pull-right']]);
$this->endBlock();
?>
<div class="row">
<div class="col-md-12">
<?php
echo DynaGrid::widget(['options' => ['id' => 'currencies-grid'], 'columns' => [['class' => \app\backend\columns\CheckboxColumn::className()], 'id', 'name', 'iso_code', 'convert_nominal', 'convert_rate', ['attribute' => 'currency_rate_provider_id', 'class' => \kartik\grid\EditableColumn::className(), 'editableOptions' => ['data' => [0 => '-'] + \app\components\Helper::getModelMap(\app\modules\shop\models\CurrencyRateProvider::className(), 'id', 'name'), 'inputType' => 'dropDownList', 'placement' => 'left', 'formOptions' => ['action' => 'update-editable']], 'filter' => \app\components\Helper::getModelMap(\app\modules\shop\models\CurrencyRateProvider::className(), 'id', 'name'), 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
if ($model === null || $model->rateProvider === null) {
return null;
}
return Html::tag('div', $model->rateProvider->name, ['class' => $model->rateProvider->name]);
}], ['class' => \app\backend\components\ActionColumn::className()]], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => $this->render('_tabs', ['currencies' => true]), 'after' => $this->blocks['add-button']]]]);
?>
</div>
</div>
示例6:
<?php
echo $form->field($model, 'overwriteUploadedFiles')->widget(SwitchInput::className());
?>
<?php
echo $form->field($model, 'daysToStoreSubmissions');
?>
<?php
BackendWidget::end();
?>
</div>
<div class="col-md-6 col-sm-12">
<?php
BackendWidget::begin(['title' => Yii::t('app', 'Email configuration'), 'options' => ['class' => 'visible-header']]);
?>
<?php
echo $form->field($model, 'spamCheckerApiKey')->dropDownList(Helper::getModelMap(SpamChecker::className(), 'behavior', 'name'));
?>
<?php
echo $form->field($model, 'emailConfig[transport]')->dropDownList(['Swift_MailTransport' => 'Mail', 'Swift_SmtpTransport' => 'SMTP', 'Swift_SendmailTransport' => 'Sendmail'])->label('Mail transport');
?>
<?php
echo $form->field($model, 'emailConfig[host]')->label('Mail server');
?>
<?php
echo $form->field($model, 'emailConfig[username]')->label('Mail username');
?>
<?php
echo $form->field($model, 'emailConfig[password]')->label('Mail password');
?>
<?php
echo $form->field($model, 'emailConfig[port]')->label('Mail server port');
示例7: jQuery
<div class="row">
<div class="col-md-4">
<?php
echo TreeWidget::widget(['treeDataRoute' => ['getTree'], 'doubleClickAction' => ContextMenuHelper::actionUrl(['index', 'returnUrl' => Helper::getReturnUrl()], ['parent_id' => 'id']), 'contextMenuItems' => ['show' => ['label' => 'Show products in category', 'icon' => 'fa fa-folder-open', 'action' => ContextMenuHelper::actionUrl(['index'], ['parent_id' => 'id'])], 'createProduct' => ['label' => 'Create product in this category', 'icon' => 'fa fa-plus-circle', 'action' => ContextMenuHelper::actionUrl(['edit', 'returnUrl' => Helper::getReturnUrl()], ['parent_id' => 'id'])], 'edit' => ['label' => 'Edit category', 'icon' => 'fa fa-pencil', 'action' => ContextMenuHelper::actionUrl(['/shop/backend-category/edit', 'returnUrl' => Helper::getReturnUrl()])], 'create' => ['label' => 'Create category', 'icon' => 'fa fa-plus-circle', 'action' => ContextMenuHelper::actionUrl(['/shop/backend-category/edit', 'returnUrl' => Helper::getReturnUrl()], ['parent_id' => 'id'])], 'delete' => ['label' => 'Delete', 'icon' => 'fa fa-trash-o', 'action' => new \yii\web\JsExpression("function(node) {\n jQuery('#delete-category-confirmation')\n .attr('data-url', '/backend/category/delete?id=' + jQuery(node.reference[0]).data('id'))\n .attr('data-items', '')\n .modal('show');\n return true;\n }")]]]);
?>
</div>
<div class="col-md-8" id="jstree-more">
<?php
echo DynaGrid::widget(['options' => ['id' => 'Product-grid'], 'columns' => [['class' => \kartik\grid\CheckboxColumn::className(), 'options' => ['width' => '10px']], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'id'], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'name'], 'slug', ['class' => \kartik\grid\EditableColumn::className(), 'attribute' => 'active', 'editableOptions' => ['data' => [0 => Yii::t('app', 'Inactive'), 1 => Yii::t('app', 'Active')], 'inputType' => 'dropDownList', 'placement' => 'left', 'formOptions' => ['action' => 'update-editable']], 'filter' => [0 => Yii::t('app', 'Inactive'), 1 => Yii::t('app', 'Active')], 'format' => 'raw', 'value' => function (Product $model) {
if ($model === null || $model->active === null) {
return null;
}
if ($model->active === 1) {
$label_class = 'label-success';
$value = 'Active';
} else {
$value = 'Inactive';
$label_class = 'label-default';
}
return \yii\helpers\Html::tag('span', Yii::t('app', $value), ['class' => "label {$label_class}"]);
}], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'price', 'editableOptions' => ['inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => 'update-editable']]], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'old_price', 'editableOptions' => ['inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => 'update-editable']]], ['attribute' => 'currency_id', 'class' => \kartik\grid\EditableColumn::className(), 'editableOptions' => ['data' => [0 => '-'] + \app\components\Helper::getModelMap(\app\modules\shop\models\Currency::className(), 'id', 'name'), 'inputType' => 'dropDownList', 'placement' => 'left', 'formOptions' => ['action' => 'update-editable']], 'filter' => \app\components\Helper::getModelMap(\app\modules\shop\models\Currency::className(), 'id', 'name'), 'format' => 'raw', 'value' => function ($model) {
if ($model === null || $model->currency === null || $model->currency_id === 0) {
return null;
}
return \yii\helpers\Html::tag('div', $model->currency->name, ['class' => $model->currency->name]);
}], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'sku', 'editableOptions' => ['inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => 'update-editable'], 'placement' => 'left']], 'date_modified', ['class' => 'app\\backend\\components\\ActionColumn', 'buttons' => [['url' => '@product', 'icon' => 'eye', 'class' => 'btn-info', 'label' => Yii::t('app', 'Preview'), 'appendReturnUrl' => false, 'url_append' => '', 'attrs' => ['model', 'mainCategory.category_group_id'], 'keyParam' => null], ['url' => 'edit', 'icon' => 'pencil', 'class' => 'btn-primary', 'label' => Yii::t('app', 'Edit')], ['url' => 'clone', 'icon' => 'copy', 'class' => 'btn-success', 'label' => Yii::t('app', 'Clone')], ['url' => 'delete', 'icon' => 'trash-o', 'class' => 'btn-danger', 'label' => Yii::t('app', 'Delete'), 'options' => ['data-action' => 'delete']]]]], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => '<h3 class="panel-title">' . $this->title . '</h3>', 'after' => $this->blocks['add-button']]]]);
?>
</div>
</div>
示例8:
*/
$allowToAddSameProduct = 0;
/**
* @var bool Count only unique products in the order
*/
$countUniqueProductsOnly = 1;
/**
* @var bool Count children products in the order
*/
$countChildrenProducts = 1;
/**
* @var int Default measure ID
*/
$defaultMeasureId = 1;
?>
</div>
<div>
<div class="col-md-6 col-sm-12">
<?php
BackendWidget::begin(['icon' => 'cogs', 'title' => Yii::t('app', 'Order stage system'), 'options' => ['class' => 'visible-header']]);
?>
<?php
echo $form->field($model, 'finalOrderStageLeaf')->dropDownList(\app\components\Helper::getModelMap(\app\modules\shop\models\OrderStageLeaf::className(), 'id', 'button_label'));
?>
<?php
BackendWidget::end();
?>
</div>
</div>
示例9:
echo $form->field(app\models\ViewObject::getByModel($model, true), 'view_id')->dropDownList(app\models\View::getAllAsArray());
?>
<?php
if (!$model->isNewRecord && is_array($model->relatedProductsArray)) {
$data = \yii\helpers\ArrayHelper::map($model->relatedProducts, 'id', 'name');
?>
<?php
echo \app\backend\widgets\Select2Ajax::widget(['initialData' => $data, 'form' => $form, 'model' => $model, 'modelAttribute' => 'relatedProductsArray', 'multiple' => true, 'searchUrl' => '/shop/backend-product/ajax-related-product', 'additional' => ['placeholder' => 'Поиск продуктов ...']]);
?>
<?php
}
?>
<?php
echo $form->field($model, 'measure_id')->dropDownList(\app\components\Helper::getModelMap(\app\modules\shop\models\Measure::className(), 'id', 'name'));
?>
<?php
BackendWidget::end();
?>
<?php
BackendWidget::begin(['title' => Yii::t('app', 'Images'), 'icon' => 'image', 'footer' => $this->blocks['submit']]);
?>
<div id="actions">
<?php
echo \yii\helpers\Html::tag('span', Icon::show('plus') . Yii::t('app', 'Add files..'), ['class' => 'btn btn-success fileinput-button']);
示例10: function
return ['class' => 'danger'];
}
return [];
}], 'columns' => [['attribute' => 'id'], ['attribute' => 'user_username', 'label' => Yii::t('app', 'User'), 'value' => function ($model, $key, $index, $column) {
if ($model === null || $model->user === null) {
return null;
}
return $model->user->username;
}], 'start_date', 'end_date', ['attribute' => 'order_stage_id', 'filter' => Helper::getModelMap(\app\modules\shop\models\OrderStage::className(), 'id', 'name_short'), 'value' => function ($model, $key, $index, $column) {
if ($model === null || $model->stage === null) {
return null;
}
return $model->stage->name_short;
}], ['attribute' => 'shipping_option_id', 'filter' => Helper::getModelMap(\app\modules\shop\models\ShippingOption::className(), 'id', 'name'), 'value' => function ($model, $key, $index, $column) {
if ($model === null || $model->shippingOption === null) {
return null;
}
return $model->shippingOption->name;
}], ['attribute' => 'payment_type_id', 'filter' => Helper::getModelMap(\app\modules\shop\models\PaymentType::className(), 'id', 'name'), 'value' => function ($model, $key, $index, $column) {
if ($model === null || $model->paymentType === null) {
return null;
}
return $model->paymentType->name;
}], 'items_count', 'total_price', ['class' => 'app\\backend\\components\\ActionColumn', 'buttons' => function ($model, $key, $index, $parent) {
$result = [['url' => '/shop/backend-order/view', 'icon' => 'eye', 'class' => 'btn-info', 'label' => Yii::t('app', 'View')]];
return $result;
}]]]);
?>
</div>
</div>
示例11:
<h3><?php
echo Yii::t('app', 'Delivery information');
?>
</h3>
<?php
echo $form->field($deliveryInformation, 'country_id')->dropDownList(\app\components\Helper::getModelMap(\app\models\Country::className(), 'id', 'name'), ['readonly' => $immutable]);
?>
<?php
echo $form->field($deliveryInformation, 'city_id')->dropDownList(\app\components\Helper::getModelMap(\app\models\City::className(), 'id', 'name'), ['readonly' => $immutable]);
?>
<?php
echo $form->field($deliveryInformation, 'zip_code')->textInput(['readonly' => $immutable]);
?>
<?php
echo $form->field($deliveryInformation, 'address')->textarea(['readonly' => $immutable]);
?>
<?php
echo $form->field($orderDeliveryInformation, 'shipping_option_id')->dropDownList(\app\components\Helper::getModelMap(\app\modules\shop\models\ShippingOption::className(), 'id', 'name'), ['readonly' => $immutable]);
?>
<?php
/** @var \app\properties\AbstractModel $abstractModel */
$abstractModel = $orderDeliveryInformation->getAbstractModel();
$abstractModel->setArrayMode(false);
foreach ($abstractModel->attributes() as $attr) {
echo $form->field($abstractModel, $attr)->textInput(['readonly' => $immutable]);
}
?>
示例12: function
<?php
/**
* @var \yii\web\View $this
* @var \app\modules\shop\models\Order $model
* @var boolean $immutable
* @var array $additional
*/
$transactionsDataProvider = $additional['transactionsDataProvider'];
echo \kartik\dynagrid\DynaGrid::widget(['options' => ['id' => 'transactions-grid'], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $transactionsDataProvider, 'hover' => true, 'panel' => false], 'columns' => [['attribute' => 'id', 'value' => function ($model, $key, $index, $column) {
/** @var \app\modules\shop\models\OrderTransaction $model */
return \yii\helpers\Html::a($model->id, \yii\helpers\Url::toRoute(['/shop/payment/transaction', 'id' => $model->id, 'othash' => $model->generateHash()]), ['class' => 'print-without-link']);
}, 'format' => 'raw', 'encodeLabel' => false], ['attribute' => 'status', 'value' => function ($model, $key, $index, $column) {
/** @var \app\modules\shop\models\OrderTransaction $model */
return $model->getTransactionStatus();
}], 'start_date', 'end_date', 'total_sum', ['attribute' => 'payment_type_id', 'filter' => \app\components\Helper::getModelMap(\app\modules\shop\models\PaymentType::className(), 'id', 'name'), 'value' => function ($model, $key, $index, $column) {
if ($model === null || $model->paymentType === null) {
return null;
}
return $model->paymentType->name;
}]]]);
示例13: foreach
?>
<?php
/** @var \app\properties\AbstractModel $abstractModel */
$abstractModel = $model->getAbstractModel();
$abstractModel->setArrayMode(false);
foreach ($abstractModel->attributes() as $attr) {
echo $form->field($abstractModel, $attr)->textInput(['readonly' => $immutable]);
}
?>
<?php
if (!empty($model->deliveryInformation)) {
?>
<h3><?php
echo Yii::t('app', 'Delivery information');
?>
</h3>
<?php
echo $form->field($model->deliveryInformation, 'country_id')->dropDownList(\app\components\Helper::getModelMap(\app\models\Country::className(), 'id', 'name'), ['readonly' => $immutable]);
?>
<?php
echo $form->field($model->deliveryInformation, 'city_id')->dropDownList(\app\components\Helper::getModelMap(\app\models\City::className(), 'id', 'name'), ['readonly' => $immutable]);
?>
<?php
echo $form->field($model->deliveryInformation, 'zip_code')->textInput(['readonly' => $immutable]);
?>
<?php
echo $form->field($model->deliveryInformation, 'address')->textarea(['readonly' => $immutable]);
?>
<?php
}
示例14:
<?php
$form = ActiveForm::begin();
?>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<?php
BackendWidget::begin(['icon' => 'tag', 'title' => Yii::t('app', 'Slider'), 'footer' => $this->blocks['submit']]);
?>
<?php
echo $form->field($model, 'name')->textInput(['maxlength' => 255]);
?>
<?php
echo $form->field($model, 'slider_handler_id')->dropDownList(\app\components\Helper::getModelMap(\app\models\SliderHandler::className(), 'id', 'name'));
?>
<?php
echo $form->field($model, 'image_width');
?>
<?php
echo $form->field($model, 'image_height');
?>
<?php
echo $form->field($model, 'resize_big_images')->checkbox();
?>
<?php
echo $form->field($model, 'resize_small_images')->checkbox();
?>
示例15: function
<div class="btn-group pull-right">
<?php
echo \yii\helpers\Html::a(Yii::t('app', 'Add'), Url::toRoute(['create', 'parent_id' => 0]), ['class' => 'btn btn-success']);
?>
<?php
echo \app\backend\widgets\RemoveAllButton::widget(['url' => Url::toRoute(['remove-all', 'returnUrl' => Yii::$app->request->url]), 'gridSelector' => '.grid-view', 'htmlOptions' => ['class' => 'btn btn-danger']]);
?>
</div>
<div class="clearfix"></div>
<?php
$this->endBlock();
?>
<div class="reviews-index">
<?php
echo DynaGrid::widget(['options' => ['id' => 'reviews-grid'], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => Html::tag('h3', $this->title, ['class' => 'panel-title']), 'after' => $this->blocks['add-button']]], 'columns' => [['class' => \kartik\grid\CheckboxColumn::className(), 'options' => ['width' => '10px']], 'id', 'author_email', ['attribute' => 'submission.form.name', 'label' => Yii::t('app', 'Form name')], ['attribute' => 'object_id', 'filter' => \app\components\Helper::getModelMap(\app\models\Object::className(), 'id', 'name'), 'label' => Yii::t('app', 'Object'), 'value' => function ($data) {
$obj = \app\models\Object::findById($data->object_id);
return is_null($obj) ? Yii::t('yii', '(not set)') : $obj->name;
}], ['class' => yii\grid\DataColumn::className(), 'attribute' => 'object_model_id', 'value' => function ($data) {
/** @var $object \app\models\Object*/
if (null !== ($object = \app\models\Object::findById($data->object_id))) {
$class = $object->object_class;
$resource = $class::findById($data->object_model_id);
if (null !== $resource) {
return $resource->name;
}
return null;
}
}], ['class' => yii\grid\DataColumn::className(), 'attribute' => 'processed_by_user_id', 'value' => function ($data) {
if (isset($data->submission)) {
if (null !== $data->submission->processed_by_user_id) {