update.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. use yii\helpers\Html;
  3. use backend\widgets\ActiveForm;
  4. use common\modules\attachment\assets\AttachmentUpdateAsset;
  5. use common\modules\attachment\models\MediaItem;
  6. /* @var $this yii\web\View */
  7. /* @var $searchModel common\modules\attachment\models\Attachment */
  8. /* @var $dataProvider yii\data\ActiveDataProvider */
  9. /* @var $model common\modules\attachment\models\Attachment */
  10. $this->title = '编辑附件';
  11. $this->params['breadcrumbs'][] = [
  12. "label" => "附件首页",
  13. "url" => [
  14. "index"
  15. ]
  16. ];
  17. $this->params['breadcrumbs'][] = $this->title;
  18. /** @var AttachmentUpdateAsset $bundle */
  19. $bundle = AttachmentUpdateAsset::register($this);
  20. ?>
  21. <div class="row">
  22. <div class="col-md-9">
  23. <?php
  24. $media = MediaItem::createFromAttachment($model);
  25. echo $this->render("_update_" . $media->getFileType(), ['model'=>$model, "media"=>$media, "bundle" => $bundle]);
  26. ?>
  27. </div>
  28. <div class="col-md-3">
  29. <?php
  30. $form = ActiveForm::begin([
  31. 'options' => [
  32. 'enctype' => 'multipart/form-data',
  33. 'class' => 'model-form'
  34. ]
  35. ]);
  36. ?>
  37. <div class="box box-solid">
  38. <div class="box-body">
  39. <?php echo $this->render("_info",["model"=>$model]);?>
  40. <?= $form->field($model, 'title')->textInput(['class' => 'form-control']); ?>
  41. <?= $form->field($model, 'description')->textarea(['class' => 'form-control']); ?>
  42. </div>
  43. <div class="box-footer">
  44. <?= Html::submitButton("更新附件", ['class' => 'btn bg-maroon margin btn-flat'])?>
  45. <?=Html::a("删除附件", ['delete','id' => $model->primaryKey], ['class' => 'btn btn-default margin btn-flat','data-item-id'=>$model->primaryKey,'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),'role' => 'delete'])?>
  46. </div>
  47. </div>
  48. <?php ActiveForm::end(); ?>
  49. </div>
  50. </div>