DocumentBaseYamlFormExporter.php in YAML Form 8
File
src/Plugin/YamlFormExporter/DocumentBaseYamlFormExporter.php
View source
<?php
namespace Drupal\yamlform\Plugin\YamlFormExporter;
use Drupal\Core\Form\FormStateInterface;
use Drupal\yamlform\YamlFormExporterBase;
abstract class DocumentBaseYamlFormExporter extends YamlFormExporterBase {
public function defaultConfiguration() {
return parent::defaultConfiguration() + [
'file_name' => 'submission-[yamlform_submission:serial]',
];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
if (isset($form['file_name'])) {
return $form;
}
$form['file_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('File name'),
'#description' => $this
->t('Submission file names must be unique.'),
'#required' => TRUE,
'#default_value' => $this->configuration['file_name'],
'#states' => [
'visible' => [
[
':input.js-yamlform-exporter' => [
'value' => 'json',
],
],
'or',
[
':input.js-yamlform-exporter' => [
'value' => 'yaml',
],
],
],
],
];
return $form;
}
}