public function BynderSearch::buildConfigurationForm in Bynder 4.0.x
Same name and namespace in other branches
- 8.3 src/Plugin/EntityBrowser/Widget/BynderSearch.php \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderSearch::buildConfigurationForm()
- 8 src/Plugin/EntityBrowser/Widget/BynderSearch.php \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderSearch::buildConfigurationForm()
- 8.2 src/Plugin/EntityBrowser/Widget/BynderSearch.php \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderSearch::buildConfigurationForm()
Overrides BynderWidgetBase::buildConfigurationForm
File
- src/
Plugin/ EntityBrowser/ Widget/ BynderSearch.php, line 38
Class
- BynderSearch
- Uses a Bynder API to search and provide entity listing in a browser's widget.
Namespace
Drupal\bynder\Plugin\EntityBrowser\WidgetCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['submit_text']['#access'] = FALSE;
foreach ($this->entityTypeManager
->getStorage('media_type')
->loadMultiple() as $type) {
/** @var \Drupal\media\MediaTypeInterface $type */
if ($type
->getSource() instanceof Bynder) {
$form['media_type']['#options'][$type
->id()] = $type
->label();
}
}
$form['media_type']['#title'] = $this
->t('Media type (Image)');
if (empty($form['media_type']['#options'])) {
$form['media_type']['#disabled'] = TRUE;
$form['media_type']['#description'] = $this
->t('You must @create_type before using this widget.', [
'@create_type' => Link::createFromRoute($this
->t('create a Bynder media type'), 'entity.media_type.add_form')
->toString(),
]);
}
else {
$form['media_type']['#required'] = FALSE;
$form['media_type']['#empty_option'] = $this
->t('- Hide images -');
$form['media_type_document'] = [
'#type' => 'select',
'#title' => $this
->t('Media type (Document)'),
'#default_value' => $this->configuration['media_type_document'],
'#required' => FALSE,
'#options' => $form['media_type']['#options'],
'#empty_option' => $this
->t('- Hide documents -'),
];
$form['media_type_video'] = [
'#type' => 'select',
'#title' => $this
->t('Media type (Video)'),
'#default_value' => $this->configuration['media_type_video'],
'#required' => FALSE,
'#options' => $form['media_type']['#options'],
'#empty_option' => $this
->t('- Hide videos -'),
];
}
return $form;
}