Beispiel #1
0
<div class="box">
<?php 
$form = ActiveForm::begin(['id' => 'edit-job-form', 'action' => 'save']);
echo Html::activeHiddenInput($model, 'id');
?>

  <div class="box-body">
    <div class="form-group">
      <?php 
echo $form->field($model->firmware, 'description')->label('Firmware')->textInput(['readonly' => true]);
?>
      <?php 
echo $form->field($model, 'description')->textInput();
?>
      <?php 
echo $form->field($model, 'scanner_id')->dropdownList(Scanner::find()->select(['name', 'id'])->indexBy('id')->column(), ['prompt' => 'Select scanner']);
?>
    </div>
    <div class="box-footer">
      <?php 
echo Button::widget(['label' => 'Save', 'options' => ['class' => 'btn btn-primary']]);
?>
      <?php 
echo Html::a('Cancel', Yii::$app->request->referrer, ['class' => 'btn btn-default']);
?>
     </div>
  </div>
<?php 
ActiveForm::end();
?>
</div>
Beispiel #2
0
<?php

use yii\grid\GridView;
use yii\helpers\Html;
use yii\data\ActiveDataProvider;
use common\models\Scanner;
use common\models\User;
/* @var $this yii\web\View */
$this->title = 'Scanners';
$this->params['breadcrumbs'][] = $this->title;
$dataProvider = new ActiveDataProvider(['query' => Scanner::find(), 'pagination' => ['pageSize' => 20]]);
?>
<div class="box">
  <div class="box-body">
    <?php 
echo Html::a('Create', 'create', ['class' => 'btn btn-primary']);
?>
  </div>
</div>

<div class="box">
  <div class="box-body">

<?php 
if (Yii::$app->user->can('listResources')) {
    echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', 'name', 'description', ['label' => 'Registered API users', 'value' => function ($model, $index, $widget) {
        return count(User::findAllByScannerId($model->id));
    }], ['attribute' => 'created_at', 'format' => ['datetime', 'php:Y-m-d H:i:s']], ['attribute' => 'updated_at', 'format' => ['datetime', 'php:Y-m-d H:i:s']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}']]]);
}
?>
  </div>