浏览代码

Adapter le formulaire "Paramètres" du backend à la nouvelle entité "Etablissement"

prodstable
keun 8 年前
父节点
当前提交
a4b7cb7764
共有 2 个文件被更改,包括 46 次插入26 次删除
  1. +12
    -2
      backend/controllers/EtablissementController.php
  2. +34
    -24
      backend/views/etablissement/update.php

+ 12
- 2
backend/controllers/EtablissementController.php 查看文件

@@ -11,6 +11,7 @@ use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\helpers\Upload ;
use common\models\Etablissement ;

/**
* UserController implements the CRUD actions for User model.
@@ -45,7 +46,7 @@ class EtablissementController extends Controller
public function actionUpdate()
{
$request = Yii::$app->request ;
$model = $this->findModel(Yii::$app->user->identity->id);
$model = $this->findModel(Yii::$app->user->identity->id_etablissement);
$logo_filename_old = $model->logo ;
$photo_filename_old = $model->photo ;
@@ -66,7 +67,7 @@ class EtablissementController extends Controller
$model->save() ;
}
return $this->redirect(['parametres', 'id' => $model->id, 'edit_ok' => true]);
return $this->redirect(['update', 'id' => $model->id, 'edit_ok' => true]);
} else {
return $this->render('update', [
'model' => $model,
@@ -75,4 +76,13 @@ class EtablissementController extends Controller
}
protected function findModel($id)
{
if (($model = Etablissement::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

+ 34
- 24
backend/views/etablissement/update.php 查看文件

@@ -15,32 +15,42 @@ $this->params['breadcrumbs'][] = 'Paramètres';

<div class="user-form">

<?php $form = ActiveForm::begin(); ?>

<?= $form->field($model, 'logo')->fileInput() ?>
<?php
if(strlen($model->logo)) {
echo '<img src="../../frontend/web/uploads/'.$model->logo.'" width="200px" /><br />' ;
echo '<input type="checkbox" name="delete_logo" id="delete_logo" /> <label for="delete_logo">Supprimer le logo</label><br /><br />' ;
}
?>
<?= $form->field($model, 'photo')->fileInput() ?>
<?php
if(strlen($model->photo)) {
echo '<img src="../../frontend/web/uploads/'.$model->photo.'" width="400px" /><br />' ;
echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />' ;
}
?>

<?= $form->field($model, 'description')->textarea() ?>

<div class="form-group">
<?= Html::submitButton('Mettre à jour', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
<?php $form = ActiveForm::begin(); ?>
<div class="col-md-6">
<?= $form->field($model, 'code_postal') ?>
<?= $form->field($model, 'ville') ?>
<?= $form->field($model, 'description')->textarea(['rows' => 10]) ?>
<div class="form-group">
<?= Html::submitButton('Mettre à jour', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
</div>

<div class="col-md-6">
<?= $form->field($model, 'logo')->fileInput() ?>
<?php
if (strlen($model->logo)) {
echo '<img src="../../frontend/web/uploads/' . $model->logo . '" width="200px" /><br />';
echo '<input type="checkbox" name="delete_logo" id="delete_logo" /> <label for="delete_logo">Supprimer le logo</label><br /><br />';
}
?>
<?= $form->field($model, 'photo')->fileInput() ?>
<?php
if (strlen($model->photo)) {
echo '<img src="../../frontend/web/uploads/' . $model->photo . '" width="400px" /><br />';
echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />';
}
?>
</div>





<?php ActiveForm::end(); ?>
</div>

<?php ActiveForm::end(); ?>
</div>

</div>



正在加载...
取消
保存