You are here

public function FooterSettingsForm::buildForm in Open Social 10.2.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_footer/src/Form/FooterSettingsForm.php \Drupal\social_footer\Form\FooterSettingsForm::buildForm()
  2. 10.0.x modules/social_features/social_footer/src/Form/FooterSettingsForm.php \Drupal\social_footer\Form\FooterSettingsForm::buildForm()
  3. 10.1.x modules/social_features/social_footer/src/Form/FooterSettingsForm.php \Drupal\social_footer\Form\FooterSettingsForm::buildForm()

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 FormInterface::buildForm

File

modules/social_features/social_footer/src/Form/FooterSettingsForm.php, line 51

Class

FooterSettingsForm
Creates a form for configuring footer block.

Namespace

Drupal\social_footer\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $block = self::configFactory()
    ->get('block.block.socialblue_footer_powered');
  if ($block) {
    $settings = $block
      ->get('settings');
  }
  $default_scheme = self::config('system.file')
    ->get('default_scheme');
  $form['logo'] = [
    '#type' => 'managed_file',
    '#title' => $this
      ->t('Logo'),
    '#upload_location' => $default_scheme . '://',
    '#upload_validators' => [
      'file_validate_is_image' => [],
    ],
    '#default_value' => [
      $settings['logo'],
    ] ?? NULL,
  ];
  $form['text'] = [
    '#type' => 'text_format',
    '#title' => $this
      ->t('Text'),
    '#default_value' => $settings['text']['value'] ?? NULL,
    '#format' => $settings['text']['format'] ?? 'basic_html',
  ];
  $form['link'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Link') ?? NULL,
  ];
  $form['link']['url'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('URL'),
    '#default_value' => $settings['link']['url'] ?? NULL,
  ];
  $form['link']['title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Title'),
    '#default_value' => $settings['link']['title'] ?? NULL,
  ];
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save configuration'),
    '#button_type' => 'primary',
  ];
  return $form;
}