【发布时间】:2015-01-23 12:53:56
【问题描述】:
我使用 yii-jui 在视图中添加一些 UI 元素,例如 datePicker。在frontend\config\main-local.php 中我设置了以下内容来更改JqueryUI 使用的主题:
$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'gjhgjhghjg87hjh8878878',
],
'assetManager' => [
'bundles' => [
'yii\jui\JuiAsset' => [
'css' =>
['themes/flick/jquery-ui.css'],
],
],
],
],
];
我尝试了以下方法来覆盖控制器操作方法中的此配置项:
public function actions() {
Yii::$app->components['assetManager'] = [
'bundles' => [
'yii\jui\JuiAsset' => [
'css' =>
['themes/dot-luv/jquery-ui.css'],
],
],
];
return parent::actions();
}
我还尝试将上面显示的Yii::$app->components['assetManager'] 的值设置为视图本身(它是表单_form.php 的部分视图)和动作调用此视图 (updateAction)。然而,所有这些尝试并没有成功改变主题。 Yii2中是否有类似CakePHP中的方法,例如Configure::write($key, $value);?
【问题讨论】:
-
为什么不能直接在文件里改?
-
@Justinas 可能是因为他正在开发一个模块或类似的东西,所以他想让代码自动配置。
标签: php oop yii2 yii-components yii2-advanced-app