function references_dialog_entityreference_edit_link in References dialog 7
Edit link callback for entity references.
1 string reference to 'references_dialog_entityreference_edit_link'
File
- ./
references_dialog.dialog_widgets.inc, line 218 - Implements dialogs for node reference and user reference fields.
Code
function references_dialog_entityreference_edit_link($element, $widget_settings, $field, $instance) {
if (isset($element['#default_value'])) {
$raw_value = $element['#default_value'] ? $element['#default_value'] : $element['#value'];
$entity_type = $field['settings']['target_type'];
// Take "label (entity id)', match the id from parenthesis.
if (preg_match("/.+\\((\\d+)\\)/", $raw_value, $matches)) {
$value = $matches[1];
}
if (isset($value)) {
$entity = current(entity_load($entity_type, array(
$value,
)));
if (entity_access('update', $entity_type, $entity)) {
return array(
array(
'title' => t('Edit'),
'href' => references_dialog_get_admin_path($entity_type, 'edit', NULL, $entity),
),
);
}
}
}
return array();
}