本文整理汇总了PHP中SettingsForm::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP SettingsForm::setAttributes方法的具体用法?PHP SettingsForm::setAttributes怎么用?PHP SettingsForm::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SettingsForm
的用法示例。
在下文中一共展示了SettingsForm::setAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$settings = Yii::app()->settings;
// 多个客户端同时操作时,每个客户端的缓存不一致,导致数据不一致,
// 故删除cache, 统一从数据库取数据
$settings->deleteCache();
$model = new SettingsForm();
if (isset($_POST['SettingsForm'])) {
$model->setAttributes($_POST['SettingsForm']);
//$settings->deleteCache();
foreach ($model->attributes as $category => $values) {
$settings->set($category, $values);
}
Yii::app()->user->setFlash('success', 'Site settings were updated.');
$this->refresh();
}
foreach ($model->attributes as $category => $values) {
$cat = $model->{$category};
foreach ($values as $key => $val) {
$cat[$key] = $settings->get($category, $key);
}
$model->{$category} = $cat;
}
$this->render('index', array('model' => $model));
}
示例2: actionIndex
public function actionIndex()
{
if (!Yii::app()->user->checkAccess('store.update')) {
$this->redirect(array('site/ErrorException', 'err_no' => 403));
}
$settings = Yii::app()->settings;
$model = new SettingsForm();
if (isset($_POST['SettingsForm'])) {
$model->setAttributes($_POST['SettingsForm']);
$settings->deleteCache();
foreach ($model->attributes as $category => $values) {
$settings->set($category, $values);
}
Yii::app()->user->setFlash('success', '<strong>Well done!</strong> Site settings were updated..');
$this->refresh();
}
foreach ($model->attributes as $category => $values) {
$cat = $model->{$category};
foreach ($values as $key => $val) {
$cat[$key] = $settings->get($category, $key);
}
$model->{$category} = $cat;
}
$this->render('index', array('model' => $model));
}
示例3: actionIndex
public function actionIndex()
{
$settings = Yii::app()->settings;
$model = new SettingsForm();
if (isset($_POST['SettingsForm'])) {
$model->setAttributes($_POST['SettingsForm']);
$settings->deleteCache();
foreach ($model->attributes as $category => $values) {
if ($category === 'logo') {
continue;
}
$settings->set($category, $values);
}
Yii::app()->user->setFlash('success', 'Site settings were updated.');
$this->refresh();
}
foreach ($model->attributes as $category => $values) {
if ($category === 'logo') {
continue;
}
$cat = $model->{$category};
foreach ($values as $key => $val) {
$cat[$key] = $settings->get($category, $key);
}
$model->{$category} = $cat;
}
$this->render('index', array('model' => $model));
}