Skip to content
Snippets Groups Projects
Commit cd2ebdf7 authored by Liam Morland's avatar Liam Morland
Browse files

Issue #3280433: Create hook_fillpdf_form_form_pre_alter()

parent f87b6c59
No related branches found
No related tags found
No related merge requests found
......@@ -5,11 +5,30 @@
* Hooks related to FillPDF module.
*/
use Drupal\fillpdf\Form\FillPdfFormForm;
/**
* @addtogroup hooks
* @{
*/
/**
* Alter a FillPdfFormForm prior to building its edit form.
*
* This is triggered in FillPdfFormForm::form().
*
* @param Drupal\fillpdf\Form\FillPdfFormForm $fillpdf_form_form
* The FillPdfFormForm object to alter.
*/
function hook_fillpdf_form_form_pre_form_build_alter(FillPdfFormForm $fillpdf_form_form): void {
// Set the default entity type for any FillPDF form to 'webform'.
$fillpdf_form = $fillpdf_form_form->getEntity();
$default_entity_type = $fillpdf_form->getDefaultEntityType();
if (!$default_entity_type) {
$fillpdf_form->set('default_entity_type', 'webform')->save();
}
}
/**
* Alter the $context in HandlePdfController::populatePdf().
*
......
......@@ -144,6 +144,9 @@ class FillPdfFormForm extends ContentEntityForm {
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
// Create hook_fillpdf_form_form_pre_form_build_alter().
$this->moduleHandler->alter('fillpdf_form_form_pre_form_build', $this);
$form = parent::form($form, $form_state);
/** @var \Drupal\fillpdf\FillPdfFormInterface $fillpdf_form */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment