Yii2: Using TinyMCE into Kartik's DetailView with custom settings

Antonio López

I'd like to insert 2amigos' TinyMCE widget in Kartik's DetailView edit mode. This is what I got by now:

       [
           'attribute' => 'myAttribute',
           'format' => 'raw',
           'type' => 'widget',
           'widgetOptions' => ['class' => TinyMce::classname()],
           'value' => $model->myAttribute,
        ], 

With this chunk I managed to show TinyMCE editor with default settings. What I'm trying to do now is to show it with custom settings defined by:

Yii::$app->params['myTinyMceParams']

In form I'm doing this:

<?= $form->field($model, 'myAttribute')->widget(TinyMce::className(), Yii::$app->params['myTinyMceParams']) ?>

Any ideas?

Antonio López

I finally found a solution, maybe not ideal but fully operative: to merge both 'class' array and rest-of-options array into 'widgetOptions':

'widgetOptions' => ArrayHelper::merge(['class' => TinyMce::classname()], Yii::$app->params['tinyMceParams']),

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related