/** * Редактирует свойства сайта */ public function actionSiteSettings() { //$settingsForm = ; $form_array = SiteSettingsForm::form(); //$form_array['title'] = Yii::t('cms', 'General settings'); $form_array['id'] = 'SiteSettings'; $form_array['activeForm'] = Form::ajaxify($form_array['id']); $form_array['buttons'] = array('refresh' => array('type' => 'submit', 'label' => Yii::t('cms', 'Save'), 'title' => Yii::t('cms', 'Save and reload the page'))); $form = new Form($form_array); $form->id = $form_array['id']; $form->model = clone Yii::app()->settings->model; $form->loadData(); $this->performAjaxValidation($form->model, null, false); if ($form->submitted('refresh')) { if ($form->model->validate()) { Yii::app()->settings->saveAll($form->model->getAttributes()); echo '1'; } else { echo '0'; } Yii::app()->end(); } $caption = array('icon' => 'settings', 'label' => Yii::t('cms', 'Site settings')); $this->render('/form', array('form' => $form, 'caption' => $caption)); }
function loadData() { if ($this->bail_out) { return; } // loading from controller/model // if controller is not set, use parent if (!$this->getController()) { return parent::loadData(); } if (empty($this->conditions)) { $this->addCondition('id', null); } try { $data = $this->getController()->get(); //->getModel()->edit_dsql()->do_getHash(); } catch (Exception $e) { // data was not loaded, it is new record } if (isset($data)) { $this->set($data); $this->loaded_from_db = true; } }