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
Comment #1
jcfiala CreditAttribution: jcfiala commentedI 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.
Comment #2
dqdDue 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:
É 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.
Comment #3
kpaxman CreditAttribution: kpaxman commentedWhat if I want unlimited links with titles?
Comment #4
tarunyaduvanshi CreditAttribution: tarunyaduvanshi as a volunteer and commentedThis is working drupal 7
thanks