- 🇧🇪Belgium kwinten-hardies Vlaams-Brabant
Hi
Can you provide an example of updating facet fields based on form states with ajax? I am using the FacetsManager class.
Saying you have a facet id "job_type". and based on that value, the location will change.I can't seem to figure it out. My code gives an error "Call to a member function getFacetSourceId() on string"
<?php $facetsource_id = 'search_api:views_page__job_search__page_1'; $jobDefault = 'Administrator'; $facets = $this->facetsManager->getFacetsByFacetSourceId($facetsource_id); if($jobDefault) { $this->facetsManager->setFacets(['job_type' => $jobDefault]); } $this->facetsManager->updateResults($facetsource_id); // Gives an error in the facet Class "DefaultFacetManager". "Call to a member function getFacetSourceId() on string" ?>
Above code lives in buildForm method.
My FacetManager is correctly declared.
I have also a declaration of "FacetsUrlGenerator". But I have no idea what to do with it.How can I retrieve the correct facet values for both job_type and location?
Thank you.