Issue #2029857 by swentel, andrewmacpherson, plopesc: Field plugin settings edit button doesn't show unless there is a settings summary .
parent
44b1f645d1
commit
bf3ac2f4c2
|
@ -0,0 +1,40 @@
|
|||
<?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 @@ abstract class DisplayOverviewBase extends OverviewBase {
|
|||
'#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 @@ class ManageDisplayTest extends FieldUiTestBase {
|
|||
$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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue