Skip to content

Commit

Permalink
Merge branch 'release-54.15.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jul 2, 2024
2 parents 0c79800 + 65405ab commit 6a57c05
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions actions/form/class.Instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ protected function initElements()

$topClass = $this->getTopClazz();

$this->getFormDataProvider()->preloadFormData(
$class->getUri(),
$topClass->getUri(),
$instance->getUri(),
$language
);
if ($instance) {
$this->getFormDataProvider()->preloadFormData(
$class->getUri(),
$topClass->getUri(),
$instance->getUri(),
$language
);
}

//get the list of properties to set in the form
$propertyCandidates = tao_helpers_form_GenerisFormFactory::getDefaultProperties();
Expand Down Expand Up @@ -145,16 +147,18 @@ protected function initElements()
$element = $elementFactory->create($property, $language);

if ($element !== null) {
$propertyInstanceValues = $this
->getFormDataProvider()
->getPropertyInstanceValues($property, $instance, $element);
foreach ($propertyInstanceValues as $valueData) {
if ($this->getFormDataProvider()->isPropertyList($property)) {
$element->setValue(
new ElementValue(tao_helpers_Uri::encode($valueData[0]), $valueData[1])
);
} else {
$element->setValue($valueData[0]);
if ($instance) {
$propertyInstanceValues = $this
->getFormDataProvider()
->getPropertyInstanceValues($property, $instance, $element);
foreach ($propertyInstanceValues as $valueData) {
if ($this->getFormDataProvider()->isPropertyList($property)) {
$element->setValue(
new ElementValue(tao_helpers_Uri::encode($valueData[0]), $valueData[1])
);
} else {
$element->setValue($valueData[0]);
}
}
}

Expand Down Expand Up @@ -196,14 +200,16 @@ protected function initElements()
$classUriElt->setValue(tao_helpers_Uri::encode($class->getUri()));
$this->form->addElement($classUriElt, true);

//add a hidden elt for the instance Uri
$instanceUriElt = tao_helpers_form_FormFactory::getElement('uri', 'Hidden');
$instanceUriElt->setValue(tao_helpers_Uri::encode($instance->getUri()));
$this->form->addElement($instanceUriElt, true);
if ($instance) {
//add a hidden elt for the instance Uri
$instanceUriElt = tao_helpers_form_FormFactory::getElement('uri', 'Hidden');
$instanceUriElt->setValue(tao_helpers_Uri::encode($instance->getUri()));
$this->form->addElement($instanceUriElt, true);

$hiddenId = tao_helpers_form_FormFactory::getElement('id', 'Hidden');
$hiddenId->setValue($instance->getUri());
$this->form->addElement($hiddenId, true);
$hiddenId = tao_helpers_form_FormFactory::getElement('id', 'Hidden');
$hiddenId->setValue($instance->getUri());
$this->form->addElement($hiddenId, true);
}
}

private function getElementFactory(): ElementMapFactory
Expand Down

0 comments on commit 6a57c05

Please sign in to comment.