function entity_browser_entity_form_field_widget_third_party_settings_form in Entity Browser 8.2
Same name and namespace in other branches
- 8 modules/entity_form/entity_browser_entity_form.module \entity_browser_entity_form_field_widget_third_party_settings_form()
Implements hook_field_widget_third_party_settings_form().
File
- modules/
entity_form/ entity_browser_entity_form.module, line 164 - Hook implementations for entity_browser_entity_form.module.
Code
function entity_browser_entity_form_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
if ($plugin instanceof InlineEntityFormComplex) {
$entity_browsers = \Drupal::service('entity_type.manager')
->getStorage('entity_browser')
->loadMultiple();
if ($entity_browsers) {
$options = [];
foreach ($entity_browsers as $entity_browser) {
$options[$entity_browser
->id()] = $entity_browser
->label();
}
$element['entity_browser_id'] = [
'#type' => 'select',
'#title' => t('Entity browser'),
'#options' => $options,
'#empty_option' => t('- None -'),
'#empty_value' => '_none',
'#default_value' => $plugin
->getThirdPartySetting('entity_browser_entity_form', 'entity_browser_id'),
];
}
else {
$element['message'] = [
'#markup' => t('There are no entity browsers available. You can create one <a href="@url">here</a>.', [
'@url' => Url::fromRoute('entity.entity_browser.collection')
->toString(),
]),
];
}
return $element;
}
}