// Сбор данных из обычных полей
form.find(':input[name]').not('[type="file"]').each(function() {
var field = $(this);
data.append(field.attr('name'), field.val());
});
<div class="category-update" style="margin-top: 100px;">
<h1><?= Html::encode($this->title) ?></h1>
<?php $form = \yii\widgets\ActiveForm::begin([
'id' => 'competence-form',
]); ?>
<?= $form->field($model, 'experience') ?>
<?= $form->field($model, 'id_subcategory')->dropDownList(Category::getAllCategories(),
[
'prompt' => 'Выбрать категорию'
]
) ?>
<div class="form-group">
<div class="col-lg-offset-3 col-lg-9">
<?= \yii\helpers\Html::submitButton(Yii::t('user', 'Сохранить'), ['class' => 'btn btn-success']) ?><br>
</div>
</div>
<?php \yii\widgets\ActiveForm::end(); ?>
public static function getAllCategories()
{
// Тут можно добавить условие выборки по условию where, добавить связь на SubCategories и так далее.
return ArrayHelper::map(self::find()->all(),'id', 'name');
}
public function actionUpdate($id)
{
$model = $this->findModel($id);
if($model->load(Yii::$app->request->post()){
if($model->save()){
return $this->redirect('путь_куда_надо_сделать_перенаправление');
}
}
$this->render('update', ['model' => $model);
}
public function saveFile()
{
$model = new Model;
$model->CV = $this->filename;
if($model->save()){
return true;
}
return false;
}
public function saveFile($id)
{
$model = Model::find()->where('id=:id', [':id => $id]);
$model->CV = $this->filename;
if($model->save()){
return true;
}
return false;
}
public function saveFile($filename)
{
$this->CV = $filename;
return $this->save(false);
}
actionUpdate_competence
actionUpdateСompetence
Перенесите в /var/www/html, дополнительно можно указать в composer.json откуда надо грузить