You are here

public function JsonapiExtrasSettingsForm::buildForm in JSON:API Extras 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/JsonapiExtrasSettingsForm.php \Drupal\jsonapi_extras\Form\JsonapiExtrasSettingsForm::buildForm()
  2. 8 src/Form/JsonapiExtrasSettingsForm.php \Drupal\jsonapi_extras\Form\JsonapiExtrasSettingsForm::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/JsonapiExtrasSettingsForm.php, line 58

Class

JsonapiExtrasSettingsForm
Configure JSON API settings for this site.

Namespace

Drupal\jsonapi_extras\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('jsonapi_extras.settings');
  $form['path_prefix'] = [
    '#title' => $this
      ->t('Path prefix'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#field_prefix' => '/',
    '#description' => $this
      ->t('The path prefix for JSON API.'),
    '#default_value' => $config
      ->get('path_prefix'),
  ];
  $form['include_count'] = [
    '#title' => $this
      ->t('Include count in collection queries'),
    '#type' => 'checkbox',
    '#description' => $this
      ->t('If activated, all collection responses will return a total record count for the provided query.'),
    '#default_value' => $config
      ->get('include_count'),
  ];
  return parent::buildForm($form, $form_state);
}