Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hey folks,
Needed to add a reference dialog to a custom field, and was thrilled to see how robust the API is for adding your own. One issue though, my custom field is a fieldset, and the default target doesn't account for that. Attaching a patch below that allows you to specify your own target, with a $key token of what the default is. Here's some example code for usage:
/**
* Implements hook_references_dialog_widgets().
*/
function image_caption_ref_references_dialog_widgets() {
return array(
'image_caption_ref' => array(
'element_type' => 'fieldset',
'dialog_form' => 'node_reference_dialog_form',
'entity_type' => 'node',
'format' => '$label [nid:$entity_id]',
'target' => '$key-entity-id', // Will become something like "edit-field-images-und-0-entity-id"
'views_query' => 'image_caption_ref_dialog_views_query',
'operations' => array(
'search' => array(
'function' => 'references_dialog_get_field_search_links',
'title' => t('Search Dialog'),
),
'edit' => array(
'function' => 'references_dialog_node_reference_edit_link',
'title' => t('Edit dialog'),
),
'add' => array(
'function' => 'references_dialog_node_reference_add_link',
'title' => t('Add dialog'),
),
),
),
);
}
Comment | File | Size | Author |
---|---|---|---|
#2 | custom_target-1928296-2.patch | 1.63 KB | Anonymous (not verified) |
|
Comments
Comment #1
wbobeirne CreditAttribution: wbobeirne commentedComment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedI re-rolled this against the latest dev