Search code examples
phpyii2yii2-basic-appyii2-widget

Yii2 - Data Not Coming To vova07 / yii2-imperavi-widget (textarea)


I've just installed vova07 / yii2-imperavi-widget through php composer.phar require --prefer-dist vova07/yii2-imperavi-widget "*". And, it's working fine for inserting any content to database table. But, I'm in awkward situation when fetching data into this this widget

I want to fetch the data. So, I created one 'value' => $postDetails['desc']. Data Not Coming to it.

<?= $form->field($modelEditPost, 'desc')->widget(Widget::className(), [
  'settings' => [
            'value' => $postDetails['desc'],
            'lang' => 'ru','minHeight' => 200,'plugins' => ['clips','fullscreen']]
]);?>

But, when i'm including

<?= $form->field($modelEditPost, 'desc')->textarea(['rows' => 6,'value'=>$postDetails['desc']]) ?> 

(which was previously present to fetch data) along with widget, Data coming to widget (But, not in textarea))

<?= $form->field($modelEditPost, 'desc')->textarea(['rows' => 6,'value'=>$postDetails['desc']]) ?>

<?= $form->field($modelEditPost, 'desc')->widget(Widget::className(), [
  'settings' => [
            'value' => $postDetails['desc'],
            'lang' => 'ru','minHeight' => 200,'plugins' => ['clips','fullscreen']]
]);?>

Actually, I want data to be fetched into widget.

Please help me to rectify this issue.


Solution

  • Use $modelEditPost->desc = $postDetails['desc']:

    $modelEditPost->desc = $postDetails['desc'];
      <?= $form->field($modelEditPost, 'desc')->widget(Widget::className(), [
    'settings' => ['lang' => 'ru','minHeight' => 200,'plugins' => ['clips','fullscreen']]
    ]);?>