Skip to content

Commit

Permalink
The "Node has ancestor" condition shouldn't be required (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhm authored Apr 19, 2022
1 parent e0152ea commit a04a72c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Plugin/Condition/NodeHasAncestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#type' => 'entity_autocomplete',
'#title' => $this->t('Parent node(s)'),
'#default_value' => $default_nids,
'#required' => TRUE,
'#required' => FALSE,
'#description' => $this->t("Can be a collection node, compound object or paged content. Accepts multiple values separated by a comma."),
'#target_type' => 'node',
'#tags' => TRUE,
Expand Down Expand Up @@ -130,9 +130,11 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Entity autocomplete store things with target IDs, for convenience just
// store the plain nid.
$this->configuration['ancestor_nids'] = array_map(function ($nid) {
return $nid['target_id'];
}, $form_state->getValue('ancestor_nids'));
if (!empty($form_state->getValue('ancestor_nids'))) {
$this->configuration['ancestor_nids'] = array_map(function ($nid) {
return $nid['target_id'];
}, $form_state->getValue('ancestor_nids'));
}
$this->configuration['parent_reference_field'] = $form_state->getValue('parent_reference_field');
parent::submitConfigurationForm($form, $form_state);
}
Expand Down

0 comments on commit a04a72c

Please sign in to comment.