function relation_dummy_field_field_instance_settings_form in Relation 8
Same name and namespace in other branches
- 7 relation_dummy_field/relation_dummy_field.module \relation_dummy_field_field_instance_settings_form()
Implements hook_field_instance_settings_form().
File
- relation_dummy_field/
relation_dummy_field.module, line 38 - A field storing arbitrary relations between entities.
Code
function relation_dummy_field_field_instance_settings_form($field, $instance) {
$bundle_key = $instance['entity_type'] . ':' . $instance['bundle'];
$bundle_wildcard_key = $instance['entity_type'] . ':' . '*';
$options = array();
foreach (RelationType::loadMultiple() as $relation_type) {
foreach ($relation_type->source_bundles as $relation_bundle_key) {
if ($bundle_key == $relation_bundle_key || $bundle_wildcard_key == $relation_bundle_key) {
$options[$relation_type
->id()] = $relation_type
->label();
}
}
}
$form['relation_type'] = array(
'#type' => 'select',
'#title' => t('Relation types'),
'#description' => t('Select all the relation types you want to display in the dummy field. Only relation types applicable to this entity bundle are show here. If no relation_types are selected, relations of all types will be displayed.'),
'#default_value' => $instance['settings']['relation_type'],
'#options' => $options,
'#multiple' => TRUE,
);
return $form;
}