Commit bbc47f05 authored by catch's avatar catch

Issue #2434745 by geertvd: Boolean field: On/Off labels are in the "storage"...

Issue #2434745 by geertvd: Boolean field: On/Off labels are in the "storage" settings but shouldn't be
parent 17e18270
......@@ -582,9 +582,9 @@ field.value.entity_reference:
# Schema for the configuration of the Boolean field type.
field.storage_settings.boolean:
type: mapping
field.field_settings.boolean:
label: 'Boolean settings'
type: mapping
mapping:
on_label:
type: string
......@@ -593,10 +593,6 @@ field.storage_settings.boolean:
type: string
label: 'Off label'
field.field_settings.boolean:
label: 'Boolean settings'
type: mapping
field.value.boolean:
type: mapping
mapping:
......
......@@ -31,11 +31,11 @@ class BooleanItem extends FieldItemBase implements OptionsProviderInterface {
/**
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
public static function defaultFieldSettings() {
return array(
'on_label' => t('On'),
'off_label' => t('Off'),
) + parent::defaultStorageSettings();
) + parent::defaultFieldSettings();
}
/**
......@@ -66,7 +66,9 @@ public static function schema(FieldStorageDefinitionInterface $field_definition)
/**
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$element = array();
$element['on_label'] = array(
'#type' => 'textfield',
'#title' => $this->t('"On" label'),
......
......@@ -69,10 +69,6 @@ function testBooleanField() {
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'boolean',
'settings' => array(
'on_label' => $on,
'off_label' => $off,
),
));
$this->field_storage->save();
$this->field = FieldConfig::create(array(
......@@ -81,6 +77,10 @@ function testBooleanField() {
'bundle' => 'entity_test',
'label' => $label,
'required' => TRUE,
'settings' => array(
'on_label' => $on,
'off_label' => $off,
),
));
$this->field->save();
......@@ -118,6 +118,16 @@ function testBooleanField() {
$this->setRawContent(drupal_render($content));
$this->assertRaw('<div class="field-item">' . $on . '</div>');
// Test if we can change the on label.
$on = $this->randomMachineName();
$edit = array(
'field[settings][on_label]' => $on,
);
$this->drupalPostForm('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name, $edit, t('Save settings'));
// Check if we see the updated labels in the creation form.
$this->drupalGet('entity_test/add');
$this->assertRaw($on);
// Test the display_label option.
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
......@@ -168,9 +178,9 @@ function testBooleanField() {
);
// Test the boolean field settings.
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name . '/storage');
$this->assertFieldById('edit-field-storage-settings-on-label', $on);
$this->assertFieldById('edit-field-storage-settings-off-label', $off);
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name);
$this->assertFieldById('edit-field-settings-on-label', $on);
$this->assertFieldById('edit-field-settings-off-label', $off);
}
}
......@@ -111,11 +111,11 @@ function testBooleanFormatterSettings() {
foreach ($settings as $values) {
// Set up the field settings.
$this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/fields/node.' . $this->bundle . '.' . $this->fieldName . '/storage');
$this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/fields/node.' . $this->bundle . '.' . $this->fieldName);
$this->drupalPostForm(NULL, array(
'field_storage[settings][on_label]' => $values[0],
'field_storage[settings][off_label]' => $values[1],
), 'Save field settings');
'field[settings][on_label]' => $values[0],
'field[settings][off_label]' => $values[1],
), 'Save settings');
// Open the Manage Display page and trigger the field settings form.
$this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/display');
......
......@@ -16,6 +16,8 @@ default_value:
-
value: 0
default_value_callback: ''
settings: { }
settings:
on_label: Yes
off_label: No
third_party_settings: { }
field_type: boolean
......@@ -7,9 +7,7 @@ id: taxonomy_term.forum_container
field_name: forum_container
entity_type: taxonomy_term
type: boolean
settings:
on_label: Yes
off_label: No
settings: { }
module: core
locked: true
cardinality: 1
......
......@@ -58,10 +58,6 @@ protected function setUp() {
'entity_type' => 'node',
'type' => 'boolean',
'cardinality' => 1,
'settings' => array(
'on_label' => 'Private',
'off_label' => 'Not private',
),
));
$field_storage->save();
......@@ -71,6 +67,10 @@ protected function setUp() {
'widget' => array(
'type' => 'options_buttons',
),
'settings' => array(
'on_label' => 'Private',
'off_label' => 'Not private',
),
))->save();
// After enabling a node access module, the access table has to be rebuild.
......
......@@ -56,10 +56,6 @@ protected function setUp() {
'entity_type' => 'node',
'type' => 'boolean',
'cardinality' => 1,
'settings' => array(
'on_label' => 'Private',
'off_label' => 'Not private',
),
));
$field_storage->save();
......@@ -69,6 +65,10 @@ protected function setUp() {
'widget' => array(
'type' => 'options_buttons',
),
'settings' => array(
'on_label' => 'Private',
'off_label' => 'Not private',
),
))->save();
// After enabling a node access module, the access table has to be rebuild.
......
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