Commit 394862da authored by catch's avatar catch

Issue #1848040 by yched: Fixed Fatal error on 'Manage display' after creating new field.

parent 5b6721a2
......@@ -101,7 +101,18 @@ public function form(array $form, array &$form_state) {
// Field rows.
foreach ($instances as $name => $instance) {
$field = field_info_field($instance['field_name']);
$display = $instance['display'][$this->view_mode];
if (isset($instance['display'][$this->view_mode])) {
$display = $instance['display'][$this->view_mode];
}
else {
$display = array(
'type' => 'hidden',
'label' => 'above',
'weight' => 0,
);
}
$table[$name] = array(
'#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
'#row_type' => 'field',
......
......@@ -167,6 +167,27 @@ function testViewModeCustom() {
$this->assertNodeViewNoText($node, 'rss', $value, "The previous settings are kept when 'rss' mode is specialized again.");
}
/**
* Tests that field instances with no explicit display settings do not break.
*/
function testNonInitializedFields() {
// Create a test field.
$edit = array(
'fields[_add_new_field][label]' => 'Test',
'fields[_add_new_field][field_name]' => 'test',
);
$this->fieldUIAddNewField('admin/structure/types/manage/' . $this->type, $edit);
// Check that no settings have been set for the 'teaser' mode.
$instance = field_info_instance('node', 'field_test', $this->type);
$this->assertFalse(isset($instance['display']['teaser']));
// Check that the field appears as 'hidden' on the 'Manage display' page
// for the 'teaser' mode.
$this->drupalGet('admin/structure/types/manage/' . $this->type . '/display/teaser');
$this->assertFieldByName('fields[field_test][type]', 'hidden', 'The field is displayed as \'hidden \'.');
}
/**
* Tests hiding the view modes fieldset when there's only one available.
*/
......
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