本文整理匯總了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));
}