Commit 5048c8e4 authored by xq1003's avatar xq1003 Committed by Damien McKenna
Browse files

Issue #3201437 by xlin, DamienMcKenna: Optional title for Selected Title.

parent e7dd56c4
......@@ -28,6 +28,7 @@ By DamienMcKenna: Unnecessary syntax change broke PHP 5.3 compatibility.
fragment stripped from URL.
#3158296 by marcosdr, opdavies, DamienMcKenna, paulocs: Enable to switch default
link protocol between HTTP and HTTPS.
#3201437 by xlin, DamienMcKenna: Optional title for Selected Title.
Link 7.x-1.7, 2019-11-14
......
......@@ -351,6 +351,18 @@ function link_field_validate($entity_type, $entity, $field, $instance, $langcode
'error_element' => array('url' => FALSE, 'title' => TRUE),
);
}
// Specific logic for when using the 'select' option on the title field.
if ($instance['settings']['title'] == 'select') {
// The title is required.
if (!empty($item['title']) && !empty($item['url'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'link_required',
'message' => t('The title field is required when a URL is provided.'),
'error_element' => array('url' => FALSE, 'title' => TRUE),
);
}
}
}
/**
......
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