Commit e1c24018 authored by alexpott's avatar alexpott

Issue #2350683 by rjacobs, Berdir: File field "Enable Description field"...

Issue #2350683 by rjacobs, Berdir: File field "Enable Description field" setting cannot be saved via instance settings in UI
parent 14032391
......@@ -192,7 +192,6 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
'#title' => t('Enable <em>Description</em> field'),
'#default_value' => isset($settings['description_field']) ? $settings['description_field'] : '',
'#description' => t('The description field allows users to enter a description about the uploaded file.'),
'#parents' => array('instance', 'settings', 'description_field'),
'#weight' => 11,
);
......
......@@ -120,4 +120,44 @@ function testDefaultFileFieldDisplay() {
$this->assertFieldByXPath('//input[@type="checkbox" and @name="' . $field_name . '[0][display]"]', NULL, 'Default file display checkbox field exists.');
$this->assertFieldByXPath('//input[@type="checkbox" and @name="' . $field_name . '[0][display]" and not(@checked)]', NULL, 'Default file display is off.');
}
/**
* Tests description toggle for field instance configuration.
*/
function testDescToggle() {
$type_name = 'test';
$field_type = 'file';
$field_name = strtolower($this->randomMachineName());
// Use the UI to add a new content type that also contains a file field.
$edit = array(
'name' => $type_name,
'type' => $type_name,
);
$this->drupalPostForm('admin/structure/types/add', $edit, t('Save and manage fields'));
$edit = array(
'new_storage_type' => $field_type,
'field_name' => $field_name,
'label' => $this->randomString(),
);
$this->drupalPostForm('/admin/structure/types/manage/' . $type_name . '/fields/add-field', $edit, t('Save and continue'));
$this->drupalPostForm(NULL, array(), t('Save field settings'));
// Ensure the description field is selected on the field instance settings
// form. That's what this test is all about.
$edit = array(
'settings[description_field]' => TRUE,
);
$this->drupalPostForm(NULL, $edit, t('Save settings'));
// Add a node of our new type and upload a file to it.
$file = current($this->drupalGetTestFiles('text'));
$title = $this->randomString();
$edit = array(
'title[0][value]' => $title,
'files[field_' . $field_name . '_0]' => drupal_realpath($file->uri),
);
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
$node = $this->drupalGetNodeByTitle($title);
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertText(t('The description may be used as the label of the link to the file.'));
}
}
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