You are here

public function WhatsappshareForm::buildForm in Whatsapp Share 8

Same name and namespace in other branches
  1. 4.0.x src/Form/WhatsappshareForm.php \Drupal\whatsappshare\Form\WhatsappshareForm::buildForm()
  2. 1.0.x src/Form/WhatsappshareForm.php \Drupal\whatsappshare\Form\WhatsappshareForm::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 ConfigFormBase::buildForm

File

src/Form/WhatsappshareForm.php, line 31
Contains Drupal\whatsappshare\Form\WhatsappshareForm.

Class

WhatsappshareForm

Namespace

Drupal\whatsappshare\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('whatsappshare.adminsettings');
  $form['whatsappshare_button_text'] = [
    '#title' => t('Button Text'),
    '#type' => 'textfield',
    '#description' => t('Insert your Whatsapp share button text.'),
    '#default_value' => $config
      ->get('whatsappshare_button_text'),
    '#required' => TRUE,
  ];
  $form['whatsappshare_button_size'] = array(
    '#title' => t('Button Size'),
    '#type' => 'select',
    '#description' => t('Select the Button Size.'),
    '#options' => array(
      'wa_btn_s' => t('Small'),
      'wa_btn_m' => t('Medium'),
      'wa_btn_l' => t('Large'),
    ),
    '#default_value' => $config
      ->get('whatsappshare_button_size'),
  );
  $form['whatsappshare_sharing_text'] = array(
    '#title' => t('Sharing text'),
    '#type' => 'textarea',
    '#description' => t('Insert Sharing text.'),
    '#required' => TRUE,
    '#cols' => 60,
    '#rows' => 5,
    '#default_value' => $config
      ->get('whatsappshare_sharing_text'),
  );
  $form['whatsappshare_sharing_location'] = array(
    '#title' => t('Sharing location'),
    '#type' => 'textfield',
    '#description' => t('Insert Sharing location using a jQuery selector. For example: #page-title or .site-branding__logo to place it after the page title or after logo (dependeds on theme).'),
    '#required' => TRUE,
    '#default_value' => $config
      ->get('whatsappshare_sharing_location'),
  );
  return parent::buildForm($form, $form_state);
}