public function YamlFormSubmissionDevelGenerate::settingsForm in YAML Form 8
File
- src/
Plugin/ DevelGenerate/ YamlFormSubmissionDevelGenerate.php, line 106
Class
- YamlFormSubmissionDevelGenerate
- Provides a YamlFormSubmissionDevelGenerate plugin.
Namespace
Drupal\yamlform\Plugin\DevelGenerateCode
public function settingsForm(array $form, FormStateInterface $form_state) {
drupal_set_message($this
->t('Please note that no emails will be sent while generating form submissions.'), 'warning');
$options = [];
foreach ($this->yamlformStorage
->loadMultiple() as $yamlform) {
$options[$yamlform
->id()] = $yamlform
->label();
}
$form['yamlform_ids'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Form'),
'#description' => $this
->t('Restrict submissions to these forms.'),
'#required' => TRUE,
'#options' => $options,
];
$form['num'] = [
'#type' => 'number',
'#title' => $this
->t('Number of submissions?'),
'#min' => 1,
'#required' => TRUE,
'#default_value' => $this
->getSetting('num'),
];
$form['kill'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Delete existing submissions in specified form before generating new submissions.'),
'#default_value' => $this
->getSetting('kill'),
];
$entity_types = \Drupal::service('entity_type.repository')
->getEntityTypeLabels(TRUE);
$form['submitted'] = [
'#type' => 'item',
'#title' => $this
->t('Submitted to'),
'#field_prefix' => '<div class="container-inline">',
'#field_suffix' => '</div>',
];
$form['submitted']['entity-type'] = [
'#type' => 'select',
'#title' => $this
->t('Entity type'),
'#title_display' => 'Invisible',
'#options' => [
'' => '',
] + $entity_types,
'#default_value' => $this
->getSetting('entity-type'),
];
$form['submitted']['entity-id'] = [
'#type' => 'number',
'#title' => $this
->t('Entity id'),
'#title_display' => 'Invisible',
'#default_value' => $this
->getSetting('entity-id'),
'#min' => 1,
'#size' => 10,
'#states' => [
'invisible' => [
':input[name="entity-type"]' => [
'value' => '',
],
],
],
];
$form['#validate'] = [
[
$this,
'validateForm',
],
];
return $form;
}