Verified Commit 78bc4e99 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(invitations) getPrefilledValues needs to be called after...

:ambulance: fix(invitations) getPrefilledValues needs to be called after providedAttributes are computed

issue #5877
Showing with 17 additions and 9 deletions
+17 -9
...@@ -170,8 +170,6 @@ class publicFormPage extends standAlonePage ...@@ -170,8 +170,6 @@ class publicFormPage extends standAlonePage
{ {
$this->template = new template($this->form['fdPublicFormTemplateType'], $this->form['fdPublicFormTemplateDN']); $this->template = new template($this->form['fdPublicFormTemplateType'], $this->form['fdPublicFormTemplateDN']);
$values = $this->getPrefilledValues();
$this->alteredAttributes = array(array(),array(),array()); $this->alteredAttributes = array(array(),array(),array());
$this->providedAttributes = array(); $this->providedAttributes = array();
$this->providedMultiValueAttributes = array(); $this->providedMultiValueAttributes = array();
...@@ -183,13 +181,7 @@ class publicFormPage extends standAlonePage ...@@ -183,13 +181,7 @@ class publicFormPage extends standAlonePage
} }
if ($this->prefill) { if ($this->prefill) {
if ($readonly) { if ($readonly) {
/* Check that mandatory readonly attributes are prefilled */ $this->alteredAttributes[1][$tab][] = $attribute;
if (
isset($values[$tab][$attribute]) ||
(!$mandatory && !$this->template->getAttribute($tab, $attribute)->isRequired())
) {
$this->alteredAttributes[1][$tab][] = $attribute;
}
} }
if ($imported) { if ($imported) {
$this->providedAttributes[] = array($tab, $attribute); $this->providedAttributes[] = array($tab, $attribute);
...@@ -203,6 +195,22 @@ class publicFormPage extends standAlonePage ...@@ -203,6 +195,22 @@ class publicFormPage extends standAlonePage
} }
} }
$values = $this->getPrefilledValues();
/* Check that mandatory readonly attributes are prefilled */
foreach ($this->alteredAttributes[1] as $tab => $attributes) {
foreach ($attributes as $key => $attribute) {
if (!isset($values[$tab][$attribute]) &&
(
(isset($this->alteredAttributes[0][$tab]) && in_array($attribute, $this->alteredAttributes[0][$tab])) ||
$this->template->getAttribute($tab, $attribute)->isRequired()
)
) {
unset($this->alteredAttributes[1][$tab][$key]);
}
}
}
$this->template->alterAttributes(...$this->alteredAttributes); $this->template->alterAttributes(...$this->alteredAttributes);
$this->template->setValues($values, TRUE); $this->template->setValues($values, TRUE);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment