public function GroupMediaSettingsForm::buildForm in Group Media 8.2
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ GroupMediaSettingsForm.php, line 65
Class
- GroupMediaSettingsForm
- Class GroupMediaSettingsForm.
Namespace
Drupal\groupmedia\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('groupmedia.settings');
$media_bundles = $this->entityTypeManager
->getStorage('media_type')
->loadMultiple();
$labels = [];
foreach ($media_bundles as $media_bundle) {
$labels[$media_bundle
->id()] = $media_bundle
->label();
}
asort($labels);
$form['tracking_enabled'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable media tracking'),
'#description' => $this
->t('If enabled the system would try to attach media items referenced in group content to corresponding group'),
'#default_value' => $config
->get('tracking_enabled'),
];
$form['bundles'] = [
'#title' => $this
->t('Media types to exclude'),
'#description' => $this
->t('By default all media bundles will be tracked. Here you can exclude certain media bundles and prevent them from being automatically attached to the group/s'),
'#type' => 'checkboxes',
'#options' => $labels,
'#default_value' => $config
->get('bundles'),
'#states' => [
'visible' => [
':input[name="tracking_enabled"]' => [
'checked' => TRUE,
],
],
],
];
return parent::buildForm($form, $form_state);
}