It's against Drupal forms standarts for a module to wrap a single field in a fieldset. Besides it adds more markup and styling issues than needed.

Comments

3magnus’s picture

Here is what I did:

@@ -143,15 +143,10 @@
 function url_field_widget_form($form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $settings = $instance['settings'];
 
-  // Display this element in a fieldset if there is only one value.
-  if ($field['cardinality'] == 1) {
-    $element['#type'] = 'fieldset';
-  }
-
   // URL field.
   $element['value'] = array(
     '#type' => 'urlfield', // Assumes elements module is enabled.
-    '#title' => t('URL'),
+    '#title' => $instance['label'],
     '#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : '',
     '#size' => $instance['widget']['settings']['size'],
     '#maxlength' => 2048,
@@ -177,6 +172,8 @@
       '#suffix' => '</div>',
     );
 
+    $element['value']['#title'] = t('URL');
+
     // Add additional styling to make both fields work together visually.
     $element['#attached']['css'][] = drupal_get_path('module', 'url') . '/url.field.css';
   }
Dave Reid’s picture

Could we check if we can use #type = 'container' instead? The key is being able to float the url/title fields next to each other.

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)