<?= \app\components\NewsWidget::widget(['param' => 'index']) ?>
писать в контроллер action или нет. То тогда вопрос будет в action там нужно render все прописывать.Uncaught TypeError: Cannot read property 'getTime' of null
at Datetimepicker.getDate (bootstrap-datetimepicker.js:405)
at Datetimepicker._setDate (bootstrap-datetimepicker.js:1146)
at Datetimepicker.reset (bootstrap-datetimepicker.js:1385)
at HTMLSpanElement.proxy (jquery.js:497)
at HTMLSpanElement.dispatch (jquery.js:4737)
at HTMLSpanElement.elemData.handle (jquery.js:4549)
d(Yii::$app->request->post());
$model = $this->findModel($id);
$model->scenario = scenario1;
public function rules()
{
return [
[['declined'], 'required', 'on' => 'scenario2'],
...
];
}
const DECLINED = 'declined';
public function scenarios()
{
return [
self::DECLINED => ['declined', 'required'],
];
}
public function actionDeclined($id)
{
$model = $this->findModel($id);
$model->scenario = Zakaz::DECLINED;
if($model->load(Yii::$app->request->post())){
$model->validate();
$model->status == Zakaz::STATUS_SUC_DISAIN ? $model->status = Zakaz::STATUS_DECLINED_DISAIN : $model->status = Zakaz::STATUS_DECLINED_MASTER;
if (!$model->save()){
print_r($model->getErrors());
} else {
$model->save();
}
return $this->redirect(['admin', '#' => $model->id_zakaz]);
} else {
return $this->renderAjax('_declined', ['model' => $model]);
}
}
<?php $comments = Comment::find()->where(['id_zakaz' => 31])->all(); ?>
<div class="comment-zakaz">
<?php foreach ($comments as $com){
echo $com->comment;
}?>
</div>
if ($model->load(Yii::$app->request->post()) && $model->save()) { // обновляем модель
return $this->redirect(['view', 'id' => $model->id]);
}
public function actionZakazedit($id)
{
$models = $this->findModel($id);
if ($_FILES){
$models->file = UploadedFile::getInstance($models, 'file');
if ($models->upload($id)){
$models->img = $id.'.'.$models->file->extension;
if(!$models->save()){
print_r($models->getErrors());
} else {
$models->save();
}
return '{}';
}
}
if($models->load(Yii::$app->request->post()) && $models->validate()){
if (!$models->save()){
print_r($models->getErrors());
} else {
$models->save();
}
return $this->redirect(['admin', '#' => $models->id_zakaz]);
} else {
return $this->renderAjax('_zakazedit', ['models' => $models]);
}
}
<?php $form = ActiveForm::begin([
'options' => ['enctype' => 'multipart/form-data'],
]); ?>
<?=$form->field($models, 'file')->widget(FileInput::className(), [
'language' => 'ru',
'options' => ['multiple' => false],
'pluginOptions' => [
'showCaption' => true,
'showRemove' => true,
'showUpload' => true,
'showPreview' => true,
'browseClass' => 'btn btn-success',
'uploadClass' => 'btn btn-info',
'removeClass' => 'btn btn-danger',
'previewFileType' => 'any',
'uploadUrl' => Url::to(['/zakaz/update', 'id' => $models->id_zakaz]),
],
]) ?>
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-primary']) ?>
<?php ActiveForm::end(); ?>
Немного не понял, как это будет выглядеть? там же для каждой роли разные условия