public function YamlFormResultsExportForm::buildForm in YAML Form 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 FormInterface::buildForm
File
- src/
Form/ YamlFormResultsExportForm.php, line 52
Class
- YamlFormResultsExportForm
- Form for form results export form.
Namespace
Drupal\yamlform\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Set the merged default (global setting), saved, and user export options
// into the form's state.
$settings_options = $this
->config('yamlform.settings')
->get('export');
$saved_options = $this->submissionExporter
->getYamlFormOptions();
$user_options = $this->submissionExporter
->getValuesFromInput($form_state
->getUserInput());
$export_options = NestedArray::mergeDeep($settings_options, $saved_options, $user_options);
// Build the form.
$this->submissionExporter
->buildExportOptionsForm($form, $form_state, $export_options);
// Build actions.
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Download'),
'#button_type' => 'primary',
];
$form['actions']['save'] = [
'#type' => 'submit',
'#value' => $this
->t('Save settings'),
'#submit' => [
'::save',
],
];
$form['actions']['delete'] = [
'#type' => 'submit',
'#value' => $this
->t('Reset settings'),
'#attributes' => [
'class' => [
'button',
'button--danger',
],
],
'#access' => $saved_options ? TRUE : FALSE,
'#submit' => [
'::delete',
],
];
return $form;
}