Skip to content
This repository was archived by the owner on Jan 5, 2018. It is now read-only.

Commit 0db207c

Browse files
committed
Issue #2671914: Implement EB configuration UI
1 parent 62f7b78 commit 0db207c

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,20 @@ protected function validateExtension($filename, $extensions) {
211211
return TRUE;
212212
}
213213

214+
/**
215+
* {@inheritdoc}
216+
*/
217+
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
218+
$configuration = $this->getConfiguration();
219+
$settings = $configuration['settings'];
220+
$form += parent::buildConfigurationForm($form, $form_state);
221+
222+
$form['dropzone_description'] = [
223+
'#type' => 'textfield',
224+
'#title' => $this->t('Dropzone drag-n-drop zone text'),
225+
'#default_value' => $settings['dropzone_description'],
226+
];
227+
228+
return $form;
229+
}
214230
}

modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,39 @@ public function submit(array &$element, array &$form, FormStateInterface $form_s
137137
$this->clearFormValues($element, $form_state);
138138
}
139139
}
140+
141+
/**
142+
* {@inheritdoc}
143+
*/
144+
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
145+
$configuration = $this->getConfiguration();
146+
$settings = $configuration['settings'];
147+
$form += parent::buildConfigurationForm($form, $form_state);
148+
149+
$options = [];
150+
$media_bundles = $this->entityManager->getBundleInfo('media');
151+
if (!empty($media_bundles)) {
152+
foreach ($media_bundles as $id => $bundle) {
153+
$options[$id] = $bundle['label'];
154+
}
155+
$disabled = FALSE;
156+
$description = $this->t('Select the type of media entity that you want to create from the uploaded files.');
157+
}
158+
else {
159+
$disabled = TRUE;
160+
$description = $this->t('You must create a media bundle before using this widget.');
161+
}
162+
163+
$form['dropzonejs_media_entity'] = [
164+
'#type' => 'select',
165+
'#title' => $this->t('Media bundle to create'),
166+
'#default_value' => $settings['dropzonejs_media_entity'],
167+
'#description' => $description,
168+
'#options' => $options,
169+
'#disabled' => $disabled,
170+
'#required' => TRUE,
171+
];
172+
173+
return $form;
174+
}
140175
}

0 commit comments

Comments
 (0)