You are here

public function TermDevelGenerate::settingsForm in Devel 8

Same name and namespace in other branches
  1. 8.3 devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\TermDevelGenerate::settingsForm()
  2. 8.2 devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\TermDevelGenerate::settingsForm()
  3. 4.x devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\TermDevelGenerate::settingsForm()

Returns the form for the plugin.

Return value

array The array of default setting values, keyed by setting names.

Overrides DevelGenerateBase::settingsForm

File

devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php, line 80

Class

TermDevelGenerate
Provides a TermDevelGenerate plugin.

Namespace

Drupal\devel_generate\Plugin\DevelGenerate

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $options = array();
  foreach ($this->vocabularyStorage
    ->loadMultiple() as $vocabulary) {
    $options[$vocabulary
      ->id()] = $vocabulary
      ->label();
  }
  $form['vids'] = array(
    '#type' => 'select',
    '#multiple' => TRUE,
    '#title' => $this
      ->t('Vocabularies'),
    '#required' => TRUE,
    '#default_value' => 'tags',
    '#options' => $options,
    '#description' => $this
      ->t('Restrict terms to these vocabularies.'),
  );
  $form['num'] = array(
    '#type' => 'number',
    '#title' => $this
      ->t('Number of terms?'),
    '#default_value' => $this
      ->getSetting('num'),
    '#required' => TRUE,
    '#min' => 0,
  );
  $form['title_length'] = array(
    '#type' => 'number',
    '#title' => $this
      ->t('Maximum number of characters in term names'),
    '#default_value' => $this
      ->getSetting('title_length'),
    '#required' => TRUE,
    '#min' => 2,
    '#max' => 255,
  );
  $form['kill'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Delete existing terms in specified vocabularies before generating new terms.'),
    '#default_value' => $this
      ->getSetting('kill'),
  );
  return $form;
}