Browse Source

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

prodstable
keun 8 years ago
parent
commit
a4b7cb7764
2 changed files with 46 additions and 26 deletions
  1. +12
    -2
      backend/controllers/EtablissementController.php
  2. +34
    -24
      backend/views/etablissement/update.php

+ 12
- 2
backend/controllers/EtablissementController.php View File

use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use common\helpers\Upload ; use common\helpers\Upload ;
use common\models\Etablissement ;


/** /**
* UserController implements the CRUD actions for User model. * UserController implements the CRUD actions for User model.
public function actionUpdate() public function actionUpdate()
{ {
$request = Yii::$app->request ; $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 ; $logo_filename_old = $model->logo ;
$photo_filename_old = $model->photo ; $photo_filename_old = $model->photo ;
$model->save() ; $model->save() ;
} }
return $this->redirect(['parametres', 'id' => $model->id, 'edit_ok' => true]);
return $this->redirect(['update', 'id' => $model->id, 'edit_ok' => true]);
} else { } else {
return $this->render('update', [ return $this->render('update', [
'model' => $model, 'model' => $model,
} }
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 View File



<div class="user-form"> <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> </div>


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

</div> </div>





Loading…
Cancel
Save