Commit d7b31279 authored by webchick's avatar webchick

Issue #1872786 by yched: Fixed Can't change widget types.

parent c77cee1c
......@@ -659,8 +659,6 @@ function field_ui_widget_type_form($form, &$form_state, FieldInstance $instance)
$field_name = $instance['field_name'];
$field = field_info_field($field_name);
$field_type = field_info_field_types($field['type']);
$widget_definition = $instance->getWidget()->getDefinition();
$bundles = field_info_bundles();
$bundle_label = $bundles[$entity_type][$bundle]['label'];
......@@ -670,10 +668,7 @@ function field_ui_widget_type_form($form, &$form_state, FieldInstance $instance)
'#field_name' => $field_name,
);
$form['basic'] = array(
'#tree' => TRUE,
);
$form['basic']['widget_type'] = array(
$form['widget_type'] = array(
'#type' => 'select',
'#title' => t('Widget type'),
'#required' => TRUE,
......
......@@ -406,4 +406,48 @@ function testDuplicateFieldName() {
$this->assertText(t('The machine-readable name is already in use. It must be unique.'));
$this->assertUrl($url, array(), 'Stayed on the same page.');
}
/**
* Tests changing the widget used by a field.
*/
function testWidgetChange() {
$url_fields = 'admin/structure/types/manage/article/fields';
$url_tags_widget = $url_fields . '/field_tags/widget-type';
// Check that the field_tags field currently uses the 'options_select'
// widget.
$instance = field_info_instance('node', 'field_tags', 'article');
$this->assertEqual($instance['widget']['type'], 'options_select');
// Check that the "Manage fields" page shows the correct widget type.
$this->drupalGet($url_fields);
$link = current($this->xpath('//a[contains(@href, :href)]', array(':href' => $url_tags_widget)));
$this->assertEqual((string) $link, 'Select list');
// Go to the 'Widget type' form and check that the correct widget is
// selected.
$this->drupalGet($url_tags_widget);
$this->assertFieldByXPath("//select[@name='widget_type']", 'options_select');
// Change the widget type.
$edit = array(
'widget_type' => 'options_buttons',
);
$this->drupalPost(NULL, $edit, t('Continue'));
// Check that the "Manage fields" page shows the correct widget type.
$link = current($this->xpath('//a[contains(@href, :href)]', array(':href' => $url_tags_widget)));
$this->assertEqual((string) $link, 'Check boxes/radio buttons');
// Check that the field uses the newly set widget.
field_cache_clear();
$instance = field_info_instance('node', 'field_tags', 'article');
$this->assertEqual($instance['widget']['type'], 'options_buttons');
// Go to the 'Widget type' form and check that the correct widget is
// selected.
$this->drupalGet($url_tags_widget);
$this->assertFieldByXPath("//select[@name='widget_type']", 'options_buttons');
}
}
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