public function actionIndex()
{
$component = $this->_component;
$attibutes = (array) \Yii::$app->request->get('attributes');
if ($attributesCallable = ArrayHelper::getValue($this->_callableData, 'attributes')) {
$attibutes = ArrayHelper::merge($attibutes, $attributesCallable);
}
if ($attibutes && !\skeeks\cms\models\CmsComponentSettings::fetchByComponentDefault($component)) {
$attributes = $attibutes;
$component->attributes = $attributes;
} else {
$component->loadDefaultSettings();
}
$rr = new RequestResponse();
if (\Yii::$app->request->isAjax && \Yii::$app->request->isPost && !\Yii::$app->request->isPjax) {
return $rr->ajaxValidateForm($component);
}
if (\Yii::$app->request->isPost && \Yii::$app->request->isPjax) {
if ($component->load(\Yii::$app->request->post()) && $component->validate()) {
if ($component->saveDefaultSettings()) {
\Yii::$app->getSession()->setFlash('success', 'Успешно сохранено');
} else {
\Yii::$app->getSession()->setFlash('error', 'Не удалось сохранить');
}
} else {
\Yii::$app->getSession()->setFlash('error', 'Не удалось сохранить');
}
}
return $this->render($this->action->id, ['component' => $component]);
}