summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Stjerneman2013-03-09 21:30:19 +0100
committerEmil Stjerneman2013-03-09 21:30:19 +0100
commit43566580eae0a34cd1c4bc641ac5da0e2571d63a (patch)
tree7f8da6ae6814b58d624a98903a1f191b5f405cbe
parenta6826a53d152dff7b7cbd4df5436bb0a5325f28b (diff)
Added #1462194: Title population for Link fields.7.x-2.6
-rw-r--r--js/linkitFieldDialog.js6
-rw-r--r--linkit.field.inc4
2 files changed, 10 insertions, 0 deletions
diff --git a/js/linkitFieldDialog.js b/js/linkitFieldDialog.js
index 5c9d1ab..673edee 100644
--- a/js/linkitFieldDialog.js
+++ b/js/linkitFieldDialog.js
@@ -30,6 +30,12 @@ Drupal.linkit.editorDialog.field = {
// Replace the field value.
Drupal.behaviors.linkit_field.replaceFieldValue(field.get(0), link);
}
+
+ // Link field can have a title field. If they have, we populate the title
+ // field with the search result title if any.
+ if (typeof field_settings.title_field != 'undefined' && typeof linkitCache.link_tmp_title != 'undefined') {
+ Drupal.behaviors.linkit_field.replaceFieldValue($('#' + field_settings.title_field).get(0), linkitCache.link_tmp_title);
+ }
}
};
diff --git a/linkit.field.inc b/linkit.field.inc
index 05b2800..2e0523a 100644
--- a/linkit.field.inc
+++ b/linkit.field.inc
@@ -89,6 +89,10 @@ function linkit_process_widget(&$element) {
// Spcial settings for link fields.
if ($element['#type'] == 'link_field') {
$field_js['data']['linkit']['fields'][$field_id]['no_slash'] = TRUE;
+ // Link fields can have a title field.
+ if (isset($instance['settings']['title']) && in_array($instance['settings']['title'], array('optional', 'required'))) {
+ $field_js['data']['linkit']['fields'][$field_id]['title_field'] = $element['#id'] . '-title';
+ }
}
// Attach js files and settings Linkit needs.