_routes.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. use yii\data\ArrayDataProvider;
  3. use yii\grid\GridView;
  4. use yii\helpers\ArrayHelper;
  5. use yii\helpers\Html;
  6. /*
  7. * To change this template, choose Tools | Templates
  8. * and open the template in the editor.
  9. */
  10. ?>
  11. <?php
  12. echo Html::beginForm();
  13. echo GridView::widget([
  14. 'dataProvider' => new ArrayDataProvider([
  15. 'id' => $type == 1 ? 'new' : 'exists',
  16. 'allModels' => $data,
  17. ]),
  18. 'columns' => [
  19. [
  20. 'class' => 'yii\\grid\\CheckboxColumn',
  21. 'checkboxOptions' => function ($model) use ($type) {
  22. return [
  23. 'value' => ArrayHelper::getValue($model, 'name'),
  24. 'checked' => $type == 1 ? true : !ArrayHelper::getValue($model, 'exists', false),
  25. ];
  26. },
  27. ],
  28. [
  29. 'class' => 'yii\\grid\\DataColumn',
  30. 'attribute' => 'name',
  31. 'contentOptions' => function ($model) {
  32. return ArrayHelper::getValue($model, 'exists', true) ? [] : ['style' => 'text-decoration: line-through;'];
  33. },
  34. ],
  35. ],
  36. ]);
  37. echo Html::submitButton($type == 1 ? 'Append' : 'Delete', [
  38. 'name' => 'Submit',
  39. 'value' => $type == 1 ? 'New' : 'Del',
  40. 'class' => 'btn btn-primary btn-flat', ]);
  41. echo Html::endForm();