Commit 68882c90 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '5877-altered-and-provided-attributes-should-be-editable' into '1.4-dev'

Resolve "Altered and provided attributes should be editable"

See merge request fusiondirectory/fd-plugins!368
parents 8a7a8211 78bc4e99
......@@ -170,8 +170,6 @@ class publicFormPage extends standAlonePage
{
$this->template = new template($this->form['fdPublicFormTemplateType'], $this->form['fdPublicFormTemplateDN']);
$values = $this->getPrefilledValues();
$this->alteredAttributes = array(array(),array(),array());
$this->providedAttributes = array();
$this->providedMultiValueAttributes = array();
......@@ -183,13 +181,7 @@ class publicFormPage extends standAlonePage
}
if ($this->prefill) {
if ($readonly) {
/* Check that mandatory readonly attributes are prefilled */
if (
isset($values[$tab][$attribute]) ||
(!$mandatory && !$this->template->getAttribute($tab, $attribute)->isRequired())
) {
$this->alteredAttributes[1][$tab][] = $attribute;
}
$this->alteredAttributes[1][$tab][] = $attribute;
}
if ($imported) {
$this->providedAttributes[] = array($tab, $attribute);
......@@ -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->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