Просмотр исходного кода

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

prodstable
keun 8 лет назад
Родитель
Сommit
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>



Загрузка…
Отмена
Сохранить