Browse Source

The "Node has ancestor" condition shouldn't be required (#867)

pull/876/head 2.2.1
Simon Hieu Mai 3 years ago committed by GitHub
parent
commit
a04a72c483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Plugin/Condition/NodeHasAncestor.php

4
src/Plugin/Condition/NodeHasAncestor.php

@ -96,7 +96,7 @@ class NodeHasAncestor extends ConditionPluginBase implements ContainerFactoryPlu
'#type' => 'entity_autocomplete', '#type' => 'entity_autocomplete',
'#title' => $this->t('Parent node(s)'), '#title' => $this->t('Parent node(s)'),
'#default_value' => $default_nids, '#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."), '#description' => $this->t("Can be a collection node, compound object or paged content. Accepts multiple values separated by a comma."),
'#target_type' => 'node', '#target_type' => 'node',
'#tags' => TRUE, '#tags' => TRUE,
@ -130,9 +130,11 @@ class NodeHasAncestor extends ConditionPluginBase implements ContainerFactoryPlu
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Entity autocomplete store things with target IDs, for convenience just // Entity autocomplete store things with target IDs, for convenience just
// store the plain nid. // store the plain nid.
if (!empty($form_state->getValue('ancestor_nids'))) {
$this->configuration['ancestor_nids'] = array_map(function ($nid) { $this->configuration['ancestor_nids'] = array_map(function ($nid) {
return $nid['target_id']; return $nid['target_id'];
}, $form_state->getValue('ancestor_nids')); }, $form_state->getValue('ancestor_nids'));
}
$this->configuration['parent_reference_field'] = $form_state->getValue('parent_reference_field'); $this->configuration['parent_reference_field'] = $form_state->getValue('parent_reference_field');
parent::submitConfigurationForm($form, $form_state); parent::submitConfigurationForm($form, $form_state);
} }

Loading…
Cancel
Save