public function FileAudioFormatter::settingsForm in File Entity (fieldable files) 8.2
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form elements for the formatter settings.
Overrides FormatterBase::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ FileAudioFormatter.php, line 92
Class
- FileAudioFormatter
- Plugin implementation of the 'file_audio' formatter.
Namespace
Drupal\file_entity\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element['controls'] = array(
'#title' => t('Show audio controls'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('controls'),
);
$element['autoplay'] = array(
'#title' => t('Autoplay'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('autoplay'),
);
$element['loop'] = array(
'#title' => t('Loop'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('loop'),
);
$element['multiple_file_behavior'] = array(
'#title' => t('Display of multiple files'),
'#type' => 'radios',
'#options' => array(
'tags' => t('Use multiple @tag tags, each with a single source.', array(
'@tag' => '<audio>',
)),
'sources' => t('Use multiple sources within a single @tag tag.', array(
'@tag' => '<audio>',
)),
),
'#default_value' => $this
->getSetting('multiple_file_behavior'),
);
return $element;
}