You are here

public function CounterSettingsInitial::buildForm in Counter 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/CounterSettingsInitial.php, line 33

Class

CounterSettingsInitial
Class AddForm.

Namespace

Drupal\counter\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('counter.settings');

  // Generate the form - settings applying to all patterns first.
  $form['counter_initial'] = array(
    '#type' => 'details',
    '#weight' => -30,
    '#title' => t('Basic settings'),
  );
  $form['counter_initial'] = array(
    '#type' => 'details',
    '#weight' => -10,
    '#title' => t('Initial Values'),
    '#description' => t("Set initial values for Site Counter."),
  );
  $form['counter_initial']['counter_initial_counter'] = array(
    '#type' => 'textfield',
    '#title' => t('Initial value of Site Counter'),
    '#default_value' => $config
      ->get('counter_initial_counter'),
    '#description' => t('Initial value of Site Counter'),
  );
  $form['counter_initial']['counter_initial_unique_visitor'] = array(
    '#type' => 'textfield',
    '#title' => t('Initial value of Unique Visitor'),
    '#default_value' => $config
      ->get('counter_initial_unique_visitor'),
    '#description' => t('Initial value of Unique Visitor'),
  );
  $form['counter_initial']['counter_initial_since'] = array(
    '#type' => 'textfield',
    '#title' => t("Replace 'Since' value with this Unix timestamp"),
    '#default_value' => $config
      ->get('counter_initial_since'),
    '#description' => t("This field type is Unix timestamp, so you must enter like: 1404671462."),
  );
  return parent::buildForm($form, $form_state);
}