@hommesresponse here's the diff:
diff --git a/docroot/modules/contrib/bootstrap_horizontal_tabs/src/Plugin/Field/FieldType/BootstrapHorizontalTabs.php b/docroot/modules/contrib/bootstrap_horizontal_tabs/src/Plugin/Field/FieldType/BootstrapHorizontalTabs.php
index c587720ad..956a42342 100644
--- a/docroot/modules/contrib/bootstrap_horizontal_tabs/src/Plugin/Field/FieldType/BootstrapHorizontalTabs.php
+++ b/docroot/modules/contrib/bootstrap_horizontal_tabs/src/Plugin/Field/FieldType/BootstrapHorizontalTabs.php
@@ -3,10 +3,10 @@
namespace Drupal\bootstrap_horizontal_tabs\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\DataDefinition;
+use Drupal\text\Plugin\Field\FieldType\TextItemBase;
/**
* Plugin implementation of the 'bootstrap_horizontal_tabs' field type.
@@ -19,12 +19,13 @@
* default_formatter = "bootstrap_horizontal_tabs"
* )
*/
-class BootstrapHorizontalTabs extends FieldItemBase {
+class BootstrapHorizontalTabs extends TextItemBase {
/**
* {@inheritdoc}
*/
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
+ parent::propertyDefinitions($field_definition);
// Prevent early t() calls by using the TranslatableMarkup.
$properties['header'] = DataDefinition::create('string')
->setLabel(new TranslatableMarkup('Tab header'))
@@ -104,4 +105,16 @@ public function getConstraints() {
return $constraints;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setValue($values, $notify = TRUE) {
+ // A hack inspired by faqfield: https://git.drupalcode.org/project/faqfield/-/merge_requests/6/diffs?commit_id=df1c965cb5656870b71db53658f400551cf88847
+ // to hook this plugin with the editor.module in making images permanent.
+ if (is_array($values) && isset($values['body_value'])) {
+ $values['value'] = $values['body_value'];
+ }
+ parent::setValue($values, $notify);
+ }
}
Related issue
https://www.drupal.org/node/2732429 →
Other modules (such as faqfield referencing the same issue) are having the same problems.
I implemented the hack that faqfield did (https://git.drupalcode.org/project/faqfield/-/merge_requests/6/diffs?com...) and on BootStrapHorizontalTabs.php and it fixed this issue.
The bug is probably due to this field inheriting from FieldItemBase. In order for the editor module to recognize the uploaded files, the field should inherit from TextItemBase as stated in https://api.drupal.org/api/drupal/core%21modules%21editor%21editor.modul...
I am able to replicate it:
Drupal: 10.3.2
bootstrap_horizontal_tabs version: 2.0.7
Steps:
1. Create a content type with a body field and horizontal tabs field.
2. Set the full HTML editor to CKEditor 5.
3. Create a new content, setting both body and horizontal tabs body field as Full HTML.
4. Insert an image using CKEditor on both body and horizontal tabs field. (in the example, A is in the body, B is in the horizontal tabs.
5. Save (published or not, it does not matter)
6. Check the Files (/admin/content/files), the image uploaded in the horizontal tabs field is set to "Temporary" even though it's being used.
Expected outcome:
Both A and B are marked as "Permanent"
Actual outcome:
A is marked "Permanent" while B is marked "Temporary"