diff --git a/src/Field.php b/src/Field.php index e8766d9..7cbbfaa 100644 --- a/src/Field.php +++ b/src/Field.php @@ -1294,11 +1294,8 @@ private function _inputHtml(mixed $value, ?ElementInterface $element, bool $stat ['type' => 'module'] ); - if ($ckeConfig->css) { - $view->registerCss($ckeConfig->css); - } - $value = $this->prepValueForInput($value, $element); + $inputId = Html::id('input-ckeditor-' . $id); $html = Html::textarea($this->handle, $value, [ 'id' => $id, 'class' => 'hidden', @@ -1311,10 +1308,15 @@ private function _inputHtml(mixed $value, ?ElementInterface $element, bool $stat ]); } + if ($ckeConfig->css) { + $view->registerCss("#{$view->namespaceInputId($inputId)} { $ckeConfig->css }"); + } + return Html::tag('div', $html, [ 'class' => array_filter([ $this->showWordCount ? 'ck-with-show-word-count' : null, ]), + 'id' => $inputId, 'data' => [ 'element-id' => $element?->id, 'config' => $this->ckeConfig,