Skip to content

Maestro inherit task: inherited data is not available during form preparation #352

Description

@jekuaitk

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

  1. 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
  2. On the inheriting task's webform, configure the os2forms_nemlogin_openid_connect authentication settings: user claim CPR and element cpr
  3. Submit the start task, then open the inheriting task's form as an authenticated user whose claim matches the inherited value.
  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions