Issue #1957670 by larowlan | sreynen: Fixed Link field labels don't show in entity forms.

8.0.x
Alex Pott 2013-04-11 00:24:37 +01:00
parent dad84f025d
commit c44404a3a3
2 changed files with 14 additions and 0 deletions

View File

@ -121,6 +121,7 @@ class LinkFieldTest extends WebTestBase {
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'label' => 'Read more about this entity',
'settings' => array(
'title' => DRUPAL_OPTIONAL,
),
@ -150,6 +151,8 @@ class LinkFieldTest extends WebTestBase {
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
// Assert label is shown.
$this->assertText('Read more about this entity');
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][url]", '', 'URL field found.');
$this->assertRaw('placeholder="http://example.com"');
@ -230,6 +233,7 @@ class LinkFieldTest extends WebTestBase {
$this->instance = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
'label' => 'Read more about this entity',
'bundle' => 'test_bundle',
'settings' => array(
'title' => DRUPAL_OPTIONAL,
@ -267,6 +271,8 @@ class LinkFieldTest extends WebTestBase {
"{$this->field['field_name']}[$langcode][1][url]" => $url2,
"{$this->field['field_name']}[$langcode][1][title]" => $title2,
);
// Assert label is shown.
$this->assertText('Read more about this entity');
$this->drupalPost(NULL, $edit, t('Save'));
preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match);
$id = $match[1];

View File

@ -176,6 +176,14 @@ function link_field_widget_form(&$form, &$form_state, $field, $instance, $langco
'#attributes' => array('class' => array('link-field-widget-attributes')),
);
// If cardinality is 1, ensure a label is output for the field by wrapping it
// in a details element.
if ($field['cardinality'] == 1) {
$element += array(
'#type' => 'fieldset',
);
}
return $element;
}