protected function YamlFormSubmissionForm::displayMessages in YAML Form 8
Display draft and previous submission status messages for this form submission.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to YamlFormSubmissionForm::displayMessages()
- YamlFormSubmissionForm::buildForm in src/
YamlFormSubmissionForm.php - Form constructor.
File
- src/
YamlFormSubmissionForm.php, line 433
Class
- YamlFormSubmissionForm
- Provides a form to collect and edit submissions.
Namespace
Drupal\yamlformCode
protected function displayMessages(array $form, FormStateInterface $form_state) {
/* @var $yamlform_submission \Drupal\yamlform\YamlFormSubmissionInterface */
$yamlform_submission = $this
->getEntity();
$yamlform = $this
->getYamlForm();
// Display test message.
if ($this
->isGet() && $this
->isRoute('entity.yamlform.test')) {
$this->messageManager
->display(YamlFormMessageManagerInterface::SUBMISSION_TEST, 'warning');
}
// Display loaded or saved draft message.
if ($yamlform_submission
->isDraft()) {
if ($form_state
->get('draft_saved')) {
$this->messageManager
->display(YamlFormMessageManagerInterface::SUBMISSION_DRAFT_SAVED);
$form_state
->set('draft_saved', FALSE);
}
elseif ($this
->isGet()) {
$this->messageManager
->display(YamlFormMessageManagerInterface::SUBMISSION_DRAFT_LOADED);
}
}
// Display link to previous submissions message when user is adding a new
// submission.
if ($this
->isGet() && ($this
->isRoute('entity.yamlform.canonical') || $this
->isYamlFormEntityReferenceFromSourceEntity()) && $yamlform
->access('submission_view_own') && ($previous_total = $this->storage
->getTotal($yamlform, $this->sourceEntity, $this
->currentUser()))) {
if ($previous_total > 1) {
$this->messageManager
->display(YamlFormMessageManagerInterface::SUBMISSIONS_PREVIOUS);
}
elseif ($yamlform_submission
->id() != $this->storage
->getLastSubmission($yamlform, $this->sourceEntity, $this
->currentUser())
->id()) {
$this->messageManager
->display(YamlFormMessageManagerInterface::SUBMISSION_PREVIOUS);
}
}
}