Comments (6)
Hi. Can you post the relevant code for your model and controller? In many cases you may not need to clear the cache manually as it's done in the model's afterSave
and afterDelete
methods. You're welcome by the way :)
from yii2-settings.
use backend\models\Settings;
use pheme\settings\SettingsAction;
class SettingsController extends \yii\web\Controller
{
public function actions()
{
return [
'index' => [
'class' => SettingsAction::className(),
'modelClass' => Settings::className(),
'viewName' => 'index'
]
];
}
}
class Settings extends Model
{
public $system_tariffs;
public $order_distance;
....
public function formName()
{
return 'AdminSettings';
}
public function rules()
{
return [
[
[
'system_tariffs',
'tariff_price_blocked_wheel',
'tariff_price_blocked_steering_wheel',
'tariff_price_truck_blocked_wheel',
'tariff_price_truck_blocked_steering_wheel',
'tariff_included_mileage',
'urgent_order_time',
'search_vehicle_timeout',
'send_all_timeout',
'vehicle_loading_timeout',
'driver_app_version',
'default_tariff_type',
'agent_order_timeout',
'intercity_service_commission',
'auto_discount_time'
],
'integer',
'min' => 0
],
[
[
'order_distance',
'commission',
'tariff_discount_website',
'first_send_distance',
'agent_order_commission',
'agent_order_timeout',
'sms_price'
],
'double',
'min' => 0
],
['credit_card_commission', 'double', 'min' => 0, 'max' => 100],
[
['first_send_distance', 'send_all_timeout', 'vehicle_loading_timeout', 'driver_app_version'],
'default',
'value' => 0
],
[['disable_agent_orders', 'check_driver_app_version'], 'boolean'],
[['service_phone'], 'string'],
];
}
}
I override Settings component class. And override method get to hardcode section param beacause i want to get on backend only backend settings, and on frontend only user settings. And i do it through section.
namespace common\components\settings;
use backend\models\Settings as SettingsModel;
class Settings extends \pheme\settings\components\Settings
{
public function get($key, $section = null, $default = null)
{
return parent::get($key, (new SettingsModel)->formName(), $default);
}
}
from yii2-settings.
You may want to configure the component's modelClass
. By default it's pheme\settings\models\BaseSetting
which is not what you seem to be using. If you do, don't forget to implement pheme\settings\models\SettingInterface
. That should fix your problem.
from yii2-settings.
by default Settings component use model pheme\settings\models\Setting. I don`t override it. If you mean, i need to create my own model and hardcode section in it, but it not fix problem with settings view.
from yii2-settings.
How are you clearing the cache? Since you're using your own controller and view for the UI it shouldn't be anything related to the component. Are there any errors in the your logs? Cache component can read and write correctly?
from yii2-settings.
Hi. I understand the problem. I have 2 projects with this module on 1 server with memcache. And both they use default cache key in settings. Thats why i get settings rawConfig from other project :(
Set custom cache key to config and all work. Thanks
from yii2-settings.
Related Issues (20)
- Exception on getting empty value which was saved as an object in db HOT 13
- Unable to locate message source for category 'extensions/yii2-settings/settings'. HOT 6
- Migration Fails with Exception: SQLSTATE[42000]: Syntax error or access violation: 1071 HOT 1
- How to seed settings HOT 6
- Custom form and upload image HOT 1
- Sort list alphabetically
- Invalid type when set type is "email" HOT 2
- Tag a new release HOT 1
- Descriptions for settings
- Custom form, numeric input problem HOT 11
- Tag 0.5 (stable) HOT 1
- migratoin error HOT 8
- Empty settings input fields saved as object HOT 11
- Using with sqlite
- please make a stable release HOT 1
- Update this extension for new version of Yii framework(2.0.14) HOT 3
- Object of class stdClass could not be converted to string
- Problem in editable save state
- problem save
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-settings.