This is the same feature as https://www.drupal.org/node/1959806 which was added in Drupal core 8.0.x, and it would be a great DX+ for custom and contrib modules. We also have at least one UX use case in core that would take advantage of that feature: #1822, and we also have a todo item for this in EntityLayoutContext::form()
, in https://github.com/backdrop/backdrop/blob/1.x/core/modules/layout/plugin...
...
$form['id'] = array(
'#title' => t('Enter the ID of a @entity', array('@entity' => $info['label'])),
'#type' => 'number',
'#default_value' => $input,
'#step' => 1,
'#min' => 1,
// @todo: Backdrop doesnt yet have a comprehensive entity autocomplete
// function. We'd need to write a custom autocomplete function that
// handles all entity types. This would be best as a core function
// rather than just for this code.
// '#autocomplete_path' => 'node/autocomplete',
'#weight' => -10,
);
...
Description:
The autocomplete field widgets provided by the Entity reference module have been refactored into a generic 'entity_autocomplete' Form API element which can be used in regular form structures (i.e. not only in entity forms).
Usage examples:
Provide a basic autocomplete element that matches node titles from all bundles:
$form['my_element'] = array( '#type' => 'entity_autocomplete', '#target_type' => 'node', // #default_value can be either an entity object or an array of entity objects. '#default_value' => $entity, );
If we want to restrict the matches to a single or a set of bundles, we can use the 'target_bundles' selection setting:
$form['my_element'] = array( '#type' => 'entity_autocomplete', '#target_type' => 'node', '#selection_handler' => 'default', // Optional. The default selection handler is pre-populated to 'default'. '#selection_settings' => array( 'target_bundles' => array('article', 'page'), ), );
For more usage examples, see the change record: New 'entity_autocomplete' form element added
Recent comments
https://www.drupal.org/project/views/issues/1266388 shows that this is an architectural issue, and requires another 2 hooks being adjusted. It would be really nice to add comments/notes to...
node access
Hmmm, from D7 ancient tomes: from https://drupal.stackexchange.com/questions/7056/limit-which-roles-can-view-a-node-basing-on-its-content-type yet https://docs.backdropcms.org/api/...
node access
I also note on this screen: "Furthermore note that content which is not published is treated in a different way by Backdrop: it can be viewed only by its author or users with the...
node access