- Issue created by @cimo75
Given a block with a text_format field created within a module, adding this block inside a layout, when it gets translated the html content is not copied over to the translated field, nor there is a ckeditor available.
If I use the same block in the main Drupal block layout ( /admin/structure/block ) the html content is copied over to the translation field, although there is no ckeditor but that I think is by design and/or another issue in core.
public function build() {
$build = [
'#type' => 'container',
'label' => ['#markup' => 'Body: '],
'#theme' => 'my_module',
];
if (!empty($this->configuration['body'])) {
$build['body'] = [
'#type' => 'processed_text',
'#text' => $this->configuration['body']['value'],
'#format' => $this->configuration['body']['format'],
];
}
return $build;
}
public function blockForm($form, FormStateInterface $form_state) {
$body = !empty($this->configuration['body']) ? $this->configuration['body'] : [];
$form['body'] = [
'#type' => 'text_format',
'#title' => 'Body',
'#format' => isset($body['format']) ? $body['format'] : 'basic_html',
'#default_value' => isset($body['value']) ? $body['value'] : '',
];
return $form;
}
public function blockSubmit($form, FormStateInterface $form_state) {
$values = $form_state->getValues();
$this->configuration['body'] = $form_state->getValue('body');
}
block.settings.my_module:
type: block_settings
label: 'Last Item block settings'
translatable: true
mapping:
body:
type: mapping
label: 'Free text with text format support'
mapping:
value:
type: text
label: 'Custom Text'
translatable: true
format:
type: string
label: 'Text format'
Active
2.13
Code