Commit 4ab79028 authored by borisson_'s avatar borisson_ Committed by borisson_
Browse files

Issue #2835091 by borisson_: Facet summary - wrong default enabled facets

parent b2c4b7a4
......@@ -401,11 +401,15 @@ class FacetsSummaryForm extends EntityForm {
$facets_summary->addProcessor($new_settings);
}
// Set our Facet Config.
$facets_summary->setFacets((array) $form_state->getValue(['facets']));
$value = $form_state->getValue('facets') ?: [];
$enabled_facets = array_filter($value, function ($item) {
return isset($item['checked']) && $item['checked'] == 1;
});
$facets_summary->setFacets((array) $enabled_facets);
$facets_summary->save();
drupal_set_message(t('Facets Summary %name has been updated.', ['%name' => $facets_summary->getName()]));
drupal_set_message($this->t('Facets Summary %name has been updated.', ['%name' => $facets_summary->getName()]));
}
/**
......
......@@ -90,9 +90,20 @@ class IntegrationTest extends FacetsTestBase {
$this->drupalGet('admin/config/search/facets');
$this->assertText('Llama');
// Go back to the facet summary and check that the facets are not checked by
// default and that they show up in the list here.
$this->drupalGet('admin/config/search/facets/facet-summary/owl/edit');
$this->assertNoText('No facets found.');
$this->assertText('Llama');
$this->assertNoFieldChecked('edit-facets-llama-checked');
// Post the form and check that no facets are checked after saving the form.
$this->drupalPostForm(NULL, [], 'Save');
$this->assertNoFieldChecked('edit-facets-llama-checked');
// Enable a facet and check it's status after saving.
$this->drupalPostForm(NULL, ['facets[llama][checked]' => TRUE], 'Save');
$this->assertFieldChecked('edit-facets-llama-checked');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment