Skip to content
Snippets Groups Projects

Resolve #2744905 "Support permanent inline-image files within answer text"

@@ -2,10 +2,10 @@
namespace Drupal\faqfield\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\text\Plugin\Field\FieldType\TextItemBase;
/**
* Plugin implementation of the 'faqfield' field type.
@@ -18,7 +18,7 @@ use Drupal\Core\TypedData\DataDefinition;
* = "faqfield_accordion"
* )
*/
class FaqFieldItem extends FieldItemBase {
class FaqFieldItem extends TextItemBase {
/**
* {@inheritdoc}
@@ -130,6 +130,12 @@ class FaqFieldItem extends FieldItemBase {
// them to be saved in 'answer' and 'answer_format'.
$values['answer_format'] = $values['answer']['format'];
$values['answer'] = $values['answer']['value'];
// Set the 'answer' text to 'value' for inline-image
// permanent status support by the core 'editor' module.
// Without having to re-factor the custom 'answer' field.
// @see: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/editor/editor.module#L560
$values['value'] = $values['answer'];
}
parent::setValue($values, $notify);
}
Loading