public function SoundCloudDefaultFormatter::settingsForm in SoundCloud field 8
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/ SoundCloudDefaultFormatter.php, line 46
Class
- SoundCloudDefaultFormatter
- Plugin implementation of the 'soundcloud_default' formatter.
Namespace
Drupal\soundcloudfield\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$elements['soundcloud_player_type'] = array(
'#title' => $this
->t('HTML5 player type'),
'#description' => $this
->t('Select which HTML5 player to use.'),
'#type' => 'select',
'#default_value' => $this
->getSetting('soundcloud_player_type'),
'#options' => array(
'classic' => 'Classic',
'visual' => 'Visual Player (new)',
),
);
$elements['soundcloud_player_width'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Width'),
'#size' => 4,
'#default_value' => $this
->getSetting('soundcloud_player_width'),
'#description' => $this
->t('Player width in percent. Default is @width.', array(
'@width' => SOUNDCLOUDFIELD_DEFAULT_WIDTH,
)),
);
$elements['soundcloud_player_height'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Height'),
'#size' => 4,
'#default_value' => $this
->getSetting('soundcloud_player_height'),
'#states' => array(
'visible' => array(
':input[name*="soundcloud_player_type"]' => array(
'value' => 'classic',
),
),
),
);
$elements['soundcloud_player_height_sets'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Height for sets'),
'#size' => 4,
'#default_value' => $this
->getSetting('soundcloud_player_height_sets'),
'#states' => array(
'visible' => array(
':input[name*="soundcloud_player_type"]' => array(
'value' => 'classic',
),
),
),
);
$elements['soundcloud_player_visual_height'] = array(
'#type' => 'select',
'#title' => $this
->t('Height of the visual player'),
'#size' => 4,
'#default_value' => $this
->getSetting('soundcloud_player_visual_height'),
'#options' => array(
300 => '300px',
450 => '450px',
600 => '600px',
),
'#states' => array(
'visible' => array(
':input[name*="soundcloud_player_type"]' => array(
'value' => 'visual',
),
),
),
);
$elements['soundcloud_player_autoplay'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Play audio automatically when loaded (autoplay).'),
'#default_value' => $this
->getSetting('soundcloud_player_autoplay'),
);
$elements['soundcloud_player_color'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Player color.'),
'#default_value' => $this
->getSetting('soundcloud_player_color'),
'#description' => $this
->t('Player color in hexadecimal format. Default is ff7700. Turn on the jQuery Colorpicker module if available.'),
);
$elements['soundcloud_player_hiderelated'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Hide related tracks.'),
'#default_value' => $this
->getSetting('soundcloud_player_hiderelated'),
);
$elements['soundcloud_player_showartwork'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Show artwork.'),
'#default_value' => $this
->getSetting('soundcloud_player_showartwork'),
);
$elements['soundcloud_player_showcomments'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Show comments.'),
'#default_value' => $this
->getSetting('soundcloud_player_showcomments'),
);
$elements['soundcloud_player_showplaycount'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Show play count.'),
'#default_value' => $this
->getSetting('soundcloud_player_showplaycount'),
);
return $elements;
}