I have noticed that when you create a link field and add the option of a title there is only one label that can be edited, this is the main field label under field settings.

In a recent project I have to create a form and the client only want to see 2 labels: "Website title" and "Website url", instead of the output given by the module "Website", "title", and "url". In order to accomplish this I had to add an extra process function, but it seems to me to much work for just a label. Here is the code, and please let me know if actually this option already exist and I didn't see it (sometimes happen):

<?php
function rwce_element_info_alter(&$type) {
  if (isset($type['link_field'])) {
    $type['link_field']['#process'][] = 'rwce_link_field_process';
  }
}

function rwce_link_field_process($element, $form_state, $complete_form) {
  switch ($element['#field_name']) {
    case 'field_web_address':
      $element['title']['#title'] = t('Website title');
      $element['url']['#title'] = t('Website url');
      break;
  }
  
  return $element;
}
?>

It would be nice to have the option of editing these "sub-labels" through the user interface.

Comments

jcfiala’s picture

Version: 7.x-1.0-alpha3 » 7.x-1.0

I don't see that as an option, so I agree, that would be an interesting change to make.

Note that #1266474: Use field label as the label for the title field was a duplicate of this, and has been closed.

dqd’s picture

Status: Active » Closed (won't fix)
Issue tags: +link module title text field

Due to the mass of repeating feature requests regarding the additional (and if you ask me unneeded) title field, the title field teeters on the brink (hopefully soon). Since even I - as one of the maintainers of the module - don't use the title field, I would like to provide some info here about how Drupal works and how you can reach your goal:

  1. use the link field for its main purpose and fill the link field with a link
  2. use the core text field for its main purpose and fill it with text
  3. call the test field link title if you want (*hint hint*)
  4. combine them both to a field group (even for multiple values) with the module field_collection.

É violá, here is your link field with a title which supports all the features, which are combinable with any text field like, tokens, html markup, translation and many more. You can even have 20 titles if you want. Or one title for 5 links? It's up to you ... if you understand how Drupals building blocks work.

kpaxman’s picture

Due to the mass of repeating feature requests regarding the additional (and if you ask me unneeded) title field, the title field teeters on the brink (hopefully soon).

What if I want unlimited links with titles?

tarunyaduvanshi’s picture

Issue summary: View changes

This is working drupal 7
thanks