diff --git a/app/src/Controller/StandardEnrollerController.php b/app/src/Controller/StandardEnrollerController.php index 4972655ae..601141bbf 100644 --- a/app/src/Controller/StandardEnrollerController.php +++ b/app/src/Controller/StandardEnrollerController.php @@ -51,8 +51,14 @@ class StandardEnrollerController extends StandardPluginController { */ public function beforeRender(\Cake\Event\EventInterface $event) { + $Petition = TableRegistry::getTableLocator()->get('Petitions'); // Make the Petition available to the view - $this->set('vv_petition', $this->petition); + $this->set( + 'vv_petition', + $Petition->findById($this->petition->id) + ->contain($Petition->getIndexContains()) + ->firstOrFail() + ); return parent::beforeRender($event); } diff --git a/app/src/View/Helper/PetitionHelper.php b/app/src/View/Helper/PetitionHelper.php index 3b4253b85..eea417c3a 100644 --- a/app/src/View/Helper/PetitionHelper.php +++ b/app/src/View/Helper/PetitionHelper.php @@ -44,29 +44,40 @@ class PetitionHelper extends Helper // The current entity, if edit or view protected ?object $entity = null; + protected ?object $petition = null; + public function initialize(array $config): void { parent::initialize($config); $this->entity = $this->getView()->get('vv_obj'); + $this->petition = $this->getView()->get('vv_petition'); $this->enrollmentAttributesTable = new EnrollmentAttributesTable(); } - /** - * Get the - * - * @param string $attribute - * - * @return array - * @since COmanage Registry v5.0.0 - */ + /** + * Get the Enrollment Attribute hardcoded configuration + * + * @param string $attribute + * + * @return array + * @since COmanage Registry v5.0.0 + */ public function getSupportedEnrollmentAttribute(string $attribute): array { return $this->enrollmentAttributesTable->supportedAttributes()[$attribute]; } + /** + * Calculate and populate the Enrollment Attributes auto view vars + * + * @since COmanage Registry v5.0.0 + */ public function populateAutoViewVars(): void { - foreach ($this->enrollmentAttributesTable->calculateAutoViewVars(2, $this->entity) as $vvar => $value) { + // XXX Find the co id + foreach ( + $this->enrollmentAttributesTable->calculateAutoViewVars($this->petition?->enrollment_flow?->co_id,$this->entity) as $vvar => $value + ) { $this->getView()->set($vvar, $value); } }