Commit 334b6e32 authored by redndahead's avatar redndahead Committed by ceanu
Browse files

Issue #1266474 by redndahead, franz, RobLoach, jcfiala, markabur: Use field...

Issue #1266474 by redndahead, franz, RobLoach, jcfiala, markabur: Use field label as the label for the title field
parent 994db97d
......@@ -46,6 +46,7 @@ function link_field_info() {
'url' => 0,
'title' => 'optional',
'title_value' => '',
'title_label_use_field_label' => FALSE,
'title_maxlength' => 128,
'enable_tokens' => 1,
'display' => array(
......@@ -107,6 +108,13 @@ function link_field_instance_settings_form($field, $instance) {
'#description' => t('This title will always be used if “Static Title” is selected above.'),
);
$form['title_label_use_field_label'] = array(
'#type' => 'checkbox',
'#title' => t('Use field label as the label for the title field'),
'#default_value' => isset($instance['settings']['title_label_use_field_label']) ? $instance['settings']['title_label_use_field_label'] : FALSE,
'#description' => t('If this is checked the field label will be hidden.'),
);
$form['title_maxlength'] = array(
'#type' => 'textfield',
'#title' => t('Max length of title field'),
......@@ -763,10 +771,21 @@ function link_field_process($element, $form_state, $complete_form) {
'#default_value' => isset($element['#value']['url']) ? $element['#value']['url'] : NULL,
);
if ($settings['title'] !== 'none' && $settings['title'] !== 'value') {
// Figure out the label of the title field.
if (!empty($settings['title_label_use_field_label'])) {
// Use the element label as the title field label.
$title_label = $element['#title'];
// Hide the field label because there is no need for the duplicate labels.
$element['#title_display'] = 'invisible';
}
else {
$title_label = t('Title');
}
$element['title'] = array(
'#type' => 'textfield',
'#maxlength' => $settings['title_maxlength'],
'#title' => t('Title'),
'#title' => $title_label,
'#description' => t('The link title is limited to @maxlength characters maximum.', array('@maxlength' => $settings['title_maxlength'])),
'#required' => ($settings['title'] == 'required' && (($element['#delta'] == 0 && $element['#required']) || !empty($element['#value']['url']))) ? TRUE : FALSE,
'#default_value' => isset($element['#value']['title']) ? $element['#value']['title'] : NULL,
......
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