Skip to content

Commit

Permalink
VACMS-15901: Removes facilities not in user's sections
Browse files Browse the repository at this point in the history
  • Loading branch information
omahane committed Jan 4, 2024
1 parent 8f2576b commit 6a48ce9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions docroot/modules/custom/va_gov_backend/va_gov_backend.module
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,12 @@ function va_gov_backend_form_alter(&$form, FormStateInterface $form_state, $form
// Only run when on a node.
// Additionally, reduce the number of times called when editing a paragraph,
// which will have a triggering_element set.
if (isset($form['#entity_type'])
&& $form['#entity_type'] === 'node'
&& (!$form_state->getTriggeringElement())) {
$base_form_id = $form_state->getBuildInfo()['base_form_id'] ?? '';
if ((!$form_state->getTriggeringElement()) && ($base_form_id === "node_form")) {
$targets = [
'field_office',
'field_listing',
'field_facility_location',
];
_va_gov_backend_dropdown_field_access($form, $targets);
}
Expand Down Expand Up @@ -1045,6 +1045,13 @@ function _va_gov_backend_dropdown_field_access(array &$form, array $targets) {
}
}
}
elseif (!empty($option_header)) {
// If not an array, it's just an option.
// If not in the allowed items array, take it out.
if (!in_array($header_key, $allowed_options)) {
unset($form[$target]['widget']['#options'][$header_key]);
}
}
}
}
}
Expand Down

0 comments on commit 6a48ce9

Please sign in to comment.