public function SharrreSettingsForm::buildForm in Share Message 8
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/ SharrreSettingsForm.php, line 35
Class
- SharrreSettingsForm
- Defines a form that configures Share Message settings.
Namespace
Drupal\sharemessage\FormCode
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
$form = parent::buildForm($form, $form_state);
$sharrre_config = $this
->config('sharemessage.sharrre');
// Check if the library configuration is valid.
if ($check_form = Sharrre::checkConfiguration(TRUE)) {
$form['check'] = $check_form;
}
$url = 'http://jster.net/library/sharrre';
$form['library_url'] = [
'#type' => 'textfield',
'#title' => $this
->t('Remote URL for Sharrre Library (minimized version)'),
'#description' => $this
->t('Set the URL for a Web-Hosted minimized version of Sharrre library (jquery.sharrre.min.js with the leading slashes), or leave empty if using the library locally. You can retrieve the library from <a href=":url">Sharrre CDN</a>.', [
':url' => $url,
]),
'#default_value' => $sharrre_config
->get('library_url'),
];
$form['default_services'] = [
'#title' => t('Default visible services'),
'#type' => 'select',
'#multiple' => TRUE,
'#options' => [
'googlePlus' => t('Google+'),
'facebook' => t('Facebook'),
'twitter' => t('Twitter'),
'digg' => t('Digg'),
'delicious' => t('Delicious'),
'stumbleupon' => t('StumpleUpon'),
'linkedin' => t('Linkedin'),
'pinterest' => t('Pinterest'),
],
'#default_value' => $sharrre_config
->get('services'),
'#size' => 10,
];
$form['sharrre_website_documentation'] = [
'#type' => 'label',
'#title' => t('See the <a href=":url">Sharrre documentation</a> page for more information.', [
':url' => 'http://sharrre.com',
]),
];
$form['shorter_total'] = [
'#type' => 'checkbox',
'#title' => t('Shorter total'),
'#description' => t('Format number like 1.2k or 5M.'),
'#default_value' => $sharrre_config
->get('shorter_total'),
];
$form['enable_counter'] = [
'#type' => 'checkbox',
'#title' => t('Counter'),
'#description' => t('Enable the total counter.'),
'#default_value' => $sharrre_config
->get('enable_counter'),
];
$form['enable_hover'] = [
'#type' => 'checkbox',
'#title' => t('Hover'),
'#description' => t('Allow displaying the sharing buttons when hovering over the counter.'),
'#default_value' => $sharrre_config
->get('enable_hover'),
'#states' => [
'invisible' => [
':input[name="enable_counter"]' => [
'checked' => FALSE,
],
],
],
];
$form['enable_tracking'] = [
'#type' => 'checkbox',
'#title' => t('Tracking'),
'#description' => t('Allow tracking social interaction with Google Analytics.'),
'#default_value' => $sharrre_config
->get('enable_tracking'),
];
return $form;
}