本文整理汇总了PHP中app\models\Authors::getAuthorsName方法的典型用法代码示例。如果您正苦于以下问题:PHP Authors::getAuthorsName方法的具体用法?PHP Authors::getAuthorsName怎么用?PHP Authors::getAuthorsName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Authors
的用法示例。
在下文中一共展示了Authors::getAuthorsName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\date\DatePicker;
/* @var $this yii\web\View */
/* @var $model app\models\BooksSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="books-search">
<?php
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>
<?php
echo $form->field($model, 'author_id')->dropDownList(\app\models\Authors::getAuthorsName());
?>
<?php
echo $form->field($model, 'name');
?>
<?php
echo $form->field($model, 'date_start')->widget(DatePicker::classname(), ['language' => 'ru']);
?>
<?php
echo $form->field($model, 'date_end')->widget(DatePicker::classname(), ['language' => 'ru']);
?>
示例2: actionAjax
public function actionAjax()
{
$request = Yii::$app->request;
$post = $request->post();
$returnArray = [];
if ($model = $this->findModel($post['id'])) {
$returnArray['author'] = \app\models\Authors::getAuthorsName($model->author_id);
$returnArray['name'] = $model->name;
$returnArray['preview'] = $model->preview;
$returnArray['date_create'] = $model->date_create;
$returnArray['date_update'] = $model->date_update;
$returnArray['date'] = $model->date;
}
echo json_encode($returnArray);
exit;
}
示例3: function
<?php
echo Html::a('Новая запись', ['create'], ['class' => 'btn btn-success']);
?>
</p>
<?php
$label = new \app\models\Books();
?>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => '', 'columns' => ['id', 'name', ['label' => $label->getAttributeLabel('preview'), 'attribute' => 'preview', 'format' => 'raw', 'value' => function ($data) {
$img_src = '/images/nophoto_100_100.jpg';
if (!empty($data->preview) && file_exists('../web/' . $data->preview)) {
$img_src = $data->preview;
}
return '
<a class="single_image" href="#"><img src="' . $img_src . '" style="width:100px;" alt=""/></a>';
}, 'filter' => ''], ['label' => $label->getAttributeLabel('author_id'), 'attribute' => 'author_id', 'format' => 'raw', 'value' => function ($data) {
return \app\models\Authors::getAuthorsName($data->author_id);
}, 'filter' => ''], ['label' => $label->getAttributeLabel('date'), 'attribute' => 'date', 'format' => 'raw', 'value' => function ($data) {
return \app\models\Books::returnDate($data->date);
}, 'filter' => ''], ['label' => $label->getAttributeLabel('date_create'), 'format' => 'raw', 'attribute' => 'date_create', 'value' => function ($data) {
return \app\models\Books::returnDate($data->date_create);
}, 'filter' => ''], ['class' => 'yii\\grid\\ActionColumn', 'header' => 'Кнопки действий', 'template' => '{update} {view} {delete}', 'buttons' => ['view' => function ($url, $model) {
return Html::a('<span data-id="' . $model->id . '" class="show_modal_books_edit glyphicon glyphicon-eye-open"></span>', $url, []);
}]]]]);
?>
</div>