Summary
MaestroWebformInheritTask::webformSubmissionFormAlter() (os2forms_forloeb) injects inherited submission data by setting #default_value on the form's render elements during hook_webform_submission_form_alter. The data is never set on the webform submission entity itself. This means any code reading $webformSubmission->getData() during form preparation — before or after the alter — does not see the inherited values.
Motivation
os2forms_nemlogin_openid_connect can restrict access to a form by requiring that a user claim (e.g. CPR) matches the value of a configured form element. Its check runs in hook_webform_submission_prepare_form (WebformHelper::checkAccess()) and reads the expected value from the submission data. In a Maestro flow where that element is filled by inheritance from a previous task, the check always fails with "Expected value not defined", due to data not being available, and the user is denied access to the task's form.
Reproducing in the case of os2forms_nemlogin_openid_connect
- Create a Maestro template with a webform task and a "Webform with Inherited submission" task inheriting from it. Both webforms share an element key, e.g.
cpr
- On the inheriting task's webform, configure the
os2forms_nemlogin_openid_connect authentication settings: user claim CPR and element cpr
- Submit the start task, then open the inheriting task's form as an authenticated user whose claim matches the inherited value.
- Get denied access
Cause
Inheriting happens too late and arguably also on the wrong layer (render array rather then entity data).
Fix
Set the inherited data on the submission entity in hook_entity_prepare_form instead of altering element default values.
Summary
MaestroWebformInheritTask::webformSubmissionFormAlter()(os2forms_forloeb) injects inherited submission data by setting#default_valueon the form's render elements duringhook_webform_submission_form_alter. The data is never set on the webform submission entity itself. This means any code reading$webformSubmission->getData()during form preparation — before or after the alter — does not see the inherited values.Motivation
os2forms_nemlogin_openid_connect can restrict access to a form by requiring that a user claim (e.g. CPR) matches the value of a configured form element. Its check runs in
hook_webform_submission_prepare_form(WebformHelper::checkAccess()) and reads the expected value from the submission data. In a Maestro flow where that element is filled by inheritance from a previous task, the check always fails with "Expected value not defined", due to data not being available, and the user is denied access to the task's form.Reproducing in the case of
os2forms_nemlogin_openid_connectcpros2forms_nemlogin_openid_connectauthentication settings: user claimCPRand elementcprCause
Inheriting happens too late and arguably also on the wrong layer (render array rather then entity data).
Fix
Set the inherited data on the submission entity in
hook_entity_prepare_forminstead of altering element default values.hook_entity_prepare_formruns before the type-specific hook (EntityForm::init()), so the access check sees the data.populateElements()fills element defaults from entity data, so form alter is not needed. This also makes WebformInheritTask does not correctly inherit files #338 redundantEntityForm::init()runs once per form lifecycle. This makes WebformInheritTask loses edits on all but the latest wizard page #336 redundant.