Skip to content

Commit

Permalink
load overrides from related item if container is 'tab' type
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz authored Feb 21, 2024
1 parent 393c502 commit 3453f4f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
15 changes: 12 additions & 3 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1439,11 +1439,20 @@ public static function validateValues($data, $itemtype, $massiveaction)
'plugin_fields_containers_id' => $data['plugin_fields_containers_id']
]);

// Apply status overrides

$status_value = null;
$relatedItem = new $data['itemtype']();
$status_field_name = PluginFieldsStatusOverride::getStatusFieldName($itemtype);
$status_overrides = array_key_exists($status_field_name, $data) && $data[$status_field_name] !== null
? PluginFieldsStatusOverride::getOverridesForItemtypeAndStatus($container->getID(), $itemtype, $data[$status_field_name])
if ($container->fields['type'] === 'dom') {
$status_value = $data[$status_field_name] ?? null;
} else {
$status_value = $relatedItem->fields[$status_field_name] ?? null;
}
// Apply status overrides
$status_overrides = $status_value !== null
? PluginFieldsStatusOverride::getOverridesForItemtypeAndStatus($container->getID(), $itemtype, $status_value)
: [];

foreach ($status_overrides as $status_override) {
if (isset($fields[$status_override['plugin_fields_fields_id']])) {
$fields[$status_override['plugin_fields_fields_id']]['is_readonly'] = $status_override['is_readonly'];
Expand Down
12 changes: 12 additions & 0 deletions templates/status_overrides.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@

<div id="container{{ rand }}" class="asset {{ bg }}">

<div class='alert alert-primary d-flex align-items-center' role='alert'>
<i class='fas fa-info-circle fa-xl'></i>
<span class='ms-2'>
{{ __("Here you can redefine the following options :") }}
<ul>
<li><i> {{__("Mandatory") }} </i></li>
<li><i>{{ __("Read-only") }} </i></li>
</ul>
{{ __("for each field, depending on the states of the element attached to the container.") }}
</span>
</div>

{% if has_fields %}
<div class="d-flex align-items-start mb-3">
<button class="btn btn-primary me-2"
Expand Down

0 comments on commit 3453f4f

Please sign in to comment.