12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- use \app\helpers\Uuid;
- use manager\models\News;
- $this->title="Редактирование статьи";
- $this->params['breadcrumbs'][] = ['label' => 'Новости', 'url' => ['newslist']];
- $this->params['breadcrumbs'][] = $this->title;
- if( !isset($id) ){
- $request = Yii::$app->request;
- $id = $request->get('id');
- }
- if( !isset($model) ){
- $model = News::findOne($id);
- if( !$model ){
- $model = new \app\models\News();
- }
- }
- if( !(isset($model->uid) && $model->uid && Uuid::isvalid($model->uid)) )
- {
- if( strlen( $model->uid ) <> 32 )
- {
- $i = 100;
- while( $i )
- {
- $uuid = Uuid::GetUUID();
- $model->uid = $uuid;
- $tmp = $model->find()->andWhere(['uid'=>$uuid])->one();
- if( !$tmp ) break;
- $i--;
- }
- }
- }
- echo $this->render('formNews', [
- 'news' => $model,
- ]);
- ?>
|