Update 2024-09-25 12:04:01
This commit is contained in:
parent
73dc7abc5d
commit
bfba10e61e
@ -31,6 +31,7 @@ class MultiSubform << (F,LightGreen) >> #RoyalBlue {
|
|||||||
- handleRegularSetMap(array $subform, array $map, ...) : bool
|
- handleRegularSetMap(array $subform, array $map, ...) : bool
|
||||||
- validGetMap(array $map) : bool
|
- validGetMap(array $map) : bool
|
||||||
- validSetMap(array $map) : bool
|
- validSetMap(array $map) : bool
|
||||||
|
- prepLinkValue(array $subform, array $setMap) : void
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of MultiSubform::__construct
|
note right of MultiSubform::__construct
|
||||||
@ -253,6 +254,13 @@ Ensures all required keys are present and have valid values.
|
|||||||
return: bool
|
return: bool
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note right of MultiSubform::prepLinkValue
|
||||||
|
Prepare the linkValue needed by the sub-subform
|
||||||
|
|
||||||
|
since: 5.0.3
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -130,6 +130,13 @@ final class MultiSubform implements MultiSubformInterface
|
|||||||
{
|
{
|
||||||
$items = []; // will delete all existing linked items :( not ideal, but real
|
$items = []; // will delete all existing linked items :( not ideal, but real
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// make sure the sub-subform:linkValue[data:guid]
|
||||||
|
// is set with the needed key if possible
|
||||||
|
// this ensures that new sub-subform data is correctly linked
|
||||||
|
$this->prepLinkValue($items, $setMap);
|
||||||
|
}
|
||||||
|
|
||||||
// Save the core data
|
// Save the core data
|
||||||
if (!$this->setSubformData($items, $setMap['_core']))
|
if (!$this->setSubformData($items, $setMap['_core']))
|
||||||
@ -516,5 +523,44 @@ final class MultiSubform implements MultiSubformInterface
|
|||||||
|
|
||||||
return true; // All checks passed
|
return true; // All checks passed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the linkValue needed by the sub-subform
|
||||||
|
*
|
||||||
|
* @param array $subform The subform data
|
||||||
|
* @param array $setMap Mapping data for processing subforms
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
private function prepLinkValue(array &$subform, array $setMap): void
|
||||||
|
{
|
||||||
|
$code_table = null;
|
||||||
|
foreach ($setMap as $key => $map)
|
||||||
|
{
|
||||||
|
if ($key === '_core')
|
||||||
|
{
|
||||||
|
$code_table = $map['table'] ?? null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($map['linkValue'], ':') !== false)
|
||||||
|
{
|
||||||
|
[$table, $field] = explode(':', $map['linkValue']);
|
||||||
|
if ($code_table !== null &&
|
||||||
|
'guid' === $field &&
|
||||||
|
$table === $code_table)
|
||||||
|
{
|
||||||
|
foreach ($subform as &$row)
|
||||||
|
{
|
||||||
|
if (empty($row['guid']))
|
||||||
|
{
|
||||||
|
$row['guid'] = $this->subform->table($table)->getGuid($field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,13 @@
|
|||||||
{
|
{
|
||||||
$items = []; // will delete all existing linked items :( not ideal, but real
|
$items = []; // will delete all existing linked items :( not ideal, but real
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// make sure the sub-subform:linkValue[data:guid]
|
||||||
|
// is set with the needed key if possible
|
||||||
|
// this ensures that new sub-subform data is correctly linked
|
||||||
|
$this->prepLinkValue($items, $setMap);
|
||||||
|
}
|
||||||
|
|
||||||
// Save the core data
|
// Save the core data
|
||||||
if (!$this->setSubformData($items, $setMap['_core']))
|
if (!$this->setSubformData($items, $setMap['_core']))
|
||||||
@ -491,3 +498,42 @@
|
|||||||
|
|
||||||
return true; // All checks passed
|
return true; // All checks passed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the linkValue needed by the sub-subform
|
||||||
|
*
|
||||||
|
* @param array $subform The subform data
|
||||||
|
* @param array $setMap Mapping data for processing subforms
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
private function prepLinkValue(array &$subform, array $setMap): void
|
||||||
|
{
|
||||||
|
$code_table = null;
|
||||||
|
foreach ($setMap as $key => $map)
|
||||||
|
{
|
||||||
|
if ($key === '_core')
|
||||||
|
{
|
||||||
|
$code_table = $map['table'] ?? null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($map['linkValue'], ':') !== false)
|
||||||
|
{
|
||||||
|
[$table, $field] = explode(':', $map['linkValue']);
|
||||||
|
if ($code_table !== null &&
|
||||||
|
'guid' === $field &&
|
||||||
|
$table === $code_table)
|
||||||
|
{
|
||||||
|
foreach ($subform as &$row)
|
||||||
|
{
|
||||||
|
if (empty($row['guid']))
|
||||||
|
{
|
||||||
|
$row['guid'] = $this->subform->table($table)->getGuid($field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user