Commit 48813a20 authored by alexpott's avatar alexpott

Issue #2144505 by tstoeckler, YesCT, Gábor Hojtsy, vijaycs85, webflo: Views...

Issue #2144505 by tstoeckler, YesCT, Gábor Hojtsy, vijaycs85, webflo: Views does not use the text format type for formatted text
parent ff4d10b7
......@@ -173,7 +173,7 @@ display:
area:
id: area
table: views
field: area
field: area_text_custom
empty: true
content: 'This view is empty.'
plugin_id: text_custom
......
......@@ -34,7 +34,7 @@ display:
relationship: none
table: views
tokenize: false
plugin_id: text
plugin_id: text_custom
node_listing_empty:
admin_label: ''
empty: true
......
......@@ -26,11 +26,8 @@ views.area.text:
label: 'Text'
mapping:
content:
type: text
label: 'The shown text of the area'
format:
type: string
label: 'The filter format the content is in'
type: text_format
label: 'The formatted text of the area'
tokenize:
type: boolean
label: 'Should replacement tokens be used from the first row'
......
......@@ -23,8 +23,12 @@ class Text extends TokenizeAreaPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['content'] = array('default' => '', 'format_key' => 'format');
$options['format'] = array('default' => NULL);
$options['content'] = array(
'contains' => array(
'value' => array('default' => ''),
'format' => array('default' => NULL),
),
);
return $options;
}
......@@ -37,32 +41,22 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['content'] = array(
'#title' => $this->t('Content'),
'#type' => 'text_format',
'#default_value' => $this->options['content'],
'#default_value' => $this->options['content']['value'],
'#rows' => 6,
'#format' => isset($this->options['format']) ? $this->options['format'] : filter_default_format(),
'#format' => isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format(),
'#editor' => FALSE,
);
}
/**
* {@inheritdoc}
*/
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
$content = $form_state->getValue(array('options', 'content'));
$form_state->setValue(array('options', 'format'), $content['format']);
$form_state->setValue(array('options', 'content'), $content['value']);
parent::submitOptionsForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function render($empty = FALSE) {
$format = isset($this->options['format']) ? $this->options['format'] : filter_default_format();
$format = isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format();
if (!$empty || !empty($this->options['empty'])) {
return array(
'#type' => 'processed_text',
'#text' => $this->tokenizeValue($this->options['content']),
'#text' => $this->tokenizeValue($this->options['content']['value']),
'#format' => $format,
);
}
......
......@@ -45,18 +45,20 @@ public function testAreaText() {
'id' => 'area',
'table' => 'views',
'field' => 'area',
'content' => $string,
'content' => array(
'value' => $string,
),
),
));
// Execute the view.
$this->executeView($view);
$view->display_handler->handlers['header']['area']->options['format'] = $this->randomString();
$view->display_handler->handlers['header']['area']->options['content']['format'] = $this->randomString();
$build = $view->display_handler->handlers['header']['area']->render();
$this->assertEqual('', drupal_render($build), 'Nonexistent format should return empty markup.');
$view->display_handler->handlers['header']['area']->options['format'] = filter_default_format();
$view->display_handler->handlers['header']['area']->options['content']['format'] = filter_default_format();
$build = $view->display_handler->handlers['header']['area']->render();
$this->assertEqual(check_markup($string), drupal_render($build), 'Existent format should return something');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment