Commit bf3ac2f4 authored by alexpott's avatar alexpott

Issue #2029857 by swentel, andrewmacpherson, plopesc: Field plugin settings...

Issue #2029857 by swentel, andrewmacpherson, plopesc: Field plugin settings edit button doesn't show unless there is a settings summary .
parent 44b1f645
<?php
/**
* @file
*
* Contains \Drupal\field_test\Plugin\Field\FieldFormatter\TestFieldNoSettingsFormatter.
*/
namespace Drupal\field_test\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
/**
* Plugin implementation of the 'field_no_settings' formatter.
*
* @FieldFormatter(
* id = "field_no_settings",
* label = @Translation("Field no settings"),
* field_types = {
* "test_field",
* },
* )
*/
class TestFieldNoSettingsFormatter extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items) {
$elements = array();
foreach ($items as $delta => $item) {
// This formatter only needs to output raw for testing.
$elements[$delta] = array('#markup' => $item->value);
}
return $elements;
}
}
......@@ -358,7 +358,10 @@ protected function buildFieldRow($field_id, FieldInstanceInterface $instance, En
'#cell_attributes' => array('class' => array('field-plugin-summary-cell')),
);
}
if ($plugin->getSettings()) {
// Check selected plugin settings to display edit link or not.
$plugin_definition = $plugin->getPluginDefinition();
if ($plugin_definition['settings']) {
$field_row['settings_edit'] = $base_button + array(
'#type' => 'image_button',
'#name' => $field_id . '_settings_edit',
......
......@@ -104,6 +104,11 @@ function testFormatterUI() {
$edit = array($fieldname => 'non empty setting');
$this->drupalPostAjaxForm(NULL, $edit, "field_test_plugin_settings_update");
$this->assertText('Default empty setting now has a value.');
// Test the no settings form behavior.
$edit = array('fields[field_test][type]' => 'field_no_settings', 'refresh_rows' => 'field_test');
$this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh')));
$this->assertNoFieldByName('field_test_settings_edit');
}
/**
......
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