Commit c44404a3 authored by alexpott's avatar alexpott

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

parent dad84f02
......@@ -121,6 +121,7 @@ function testLinkTitle() {
'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 @@ function testLinkTitle() {
// 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 @@ function testLinkFormatter() {
$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 @@ function testLinkFormatter() {
"{$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];
......
......@@ -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;
}
......
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