Skip to content
Snippets Groups Projects

Issue #3278852: Display message on FillPDF form pages when there are not fillable fields

Merged Issue #3278852: Display message on FillPDF form pages when there are not fillable fields
Merged Liam Morland requested to merge issue/fillpdf-3278852:3278852-displau-message-on into 5.0.x
2 files
+ 23
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -138,6 +138,13 @@ class FillPdfFormForm extends ContentEntityForm {
@@ -138,6 +138,13 @@ class FillPdfFormForm extends ContentEntityForm {
/** @var \Drupal\fillpdf\FillPdfFormInterface $fillpdf_form */
/** @var \Drupal\fillpdf\FillPdfFormInterface $fillpdf_form */
$fillpdf_form = $this->entity;
$fillpdf_form = $this->entity;
 
$existing_fields = $fillpdf_form->getFormFields();
 
 
if (!count($existing_fields)) {
 
$fillpdf_form_fields_empty_message = $this->t('PDF does not contain fillable fields.');
 
$this->messenger()->addWarning($fillpdf_form_fields_empty_message);
 
}
 
$form['title']['token_tree'] = $this->adminFormHelper->getAdminTokenForm();
$form['title']['token_tree'] = $this->adminFormHelper->getAdminTokenForm();
// @todo Encapsulate this logic into a ::getDefaultEntityType() method on FillPdfForm
// @todo Encapsulate this logic into a ::getDefaultEntityType() method on FillPdfForm
@@ -397,9 +404,22 @@ class FillPdfFormForm extends ContentEntityForm {
@@ -397,9 +404,22 @@ class FillPdfFormForm extends ContentEntityForm {
$form['user_password']['#group'] = 'security';
$form['user_password']['#group'] = 'security';
// @todo Add a button to let them attempt re-parsing if it failed.
// @todo Add a button to let them attempt re-parsing if it failed.
$form['fillpdf_fields']['fields'] = FillPdf::embedView('fillpdf_form_fields',
if (count($existing_fields)) {
'block_1',
$form['fillpdf_fields']['fields'] = FillPdf::embedView('fillpdf_form_fields',
$fillpdf_form->id());
'block_1',
 
$fillpdf_form->id());
 
}
 
else {
 
$form['fillpdf_fields'] = [
 
'#theme' => 'status_messages',
 
'#message_list' => [
 
'warning' => [$fillpdf_form_fields_empty_message],
 
],
 
'#status_headings' => [
 
'warning' => t('Warning message'),
 
],
 
];
 
}
$form['fillpdf_fields']['#weight'] = 100;
$form['fillpdf_fields']['#weight'] = 100;
Loading