Reputation: 13552
I have using the datePicker from yii2-jui and I want to change the Jquery Ui theme used.
I tried harded coded change in myapp\vendor\yiisoft\yii2-jui\JuiAsset.php
class JuiAsset extends AssetBundle
{
public $sourcePath = '@bower/jquery-ui';
public $js = [
'jquery-ui.js',
];
public $css = [
'themes/THE_OTHER_THEME/jquery-ui.css',
];
public $depends = [
'yii\web\JqueryAsset',
];
}
Here are a snippet of the _form
view:
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\jui\DatePicker;
/* @var $this yii\web\View */
/* @var $model frontend\models\Profile */
/* @var $form yii\widgets\ActiveForm */
?>
...
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'birthdate')->widget(DatePicker::className(), ['clientOptions' => ['dateFormat' => 'yy-mm-dd']]) ?>
However, this way is not oop solution to get what I want. I don't able to know what I have to do in my view _form.php
to make it able to override the JuiAsset object's property $css
Upvotes: 0
Views: 2297
Reputation: 1
a bit old, but you should put the assetManager override in your config/web.php file under 'components' like so:
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'assetManager' => [
'bundles' => [
'yii\jui\JuiAsset' => [
'css' => [
'themes/flick/jquery-ui.css',
]
]
]
],
],];
i just tested this as i was looking for something simmilar, worked just fine
Upvotes: 0
Reputation: 9367
Not only that is not OOP but modifying core Yii files is bad.
2 options:
EDIT: You told me you are looking for something in the comments
Yii::$app->set('assetManager' , [
'class' => 'yii\web\AssetManager',
'bundles' => [
'yii\widgets\ActiveFormAsset' => [
'js' => [],
'depends' => [
'yii\adminUi\assetsBundle\AdminUiActiveForm',
],
],
'yii\grid\GridViewAsset' => [
'depends' => [
'backend\assets\AppAsset'
],
],
],
'linkAssets' => true,
]);
Upvotes: 1