public function SocialSearchApiSplitProfileTerms::validateExposed in Open Social 10.2.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_profile/src/Plugin/views/filter/SocialSearchApiSplitProfileTerms.php \Drupal\social_profile\Plugin\views\filter\SocialSearchApiSplitProfileTerms::validateExposed()
File
- modules/
social_features/ social_profile/ src/ Plugin/ views/ filter/ SocialSearchApiSplitProfileTerms.php, line 122
Class
- SocialSearchApiSplitProfileTerms
- Defines a filter for filtering on taxonomy term references.
Namespace
Drupal\social_profile\Plugin\views\filterCode
public function validateExposed(&$form, FormStateInterface $form_state) {
if ($this->field !== 'field_profile_profile_tag' || !$this->profileTagService
->allowSplit()) {
parent::validateExposed($form, $form_state);
return;
}
$profile_tag_values = [];
$identifier = $this->options['expose']['identifier'];
// Get the main categories.
$categories = $this->profileTagService
->getCategories();
// Get form values.
$form_values = $form_state
->getValues();
foreach ($categories as $tid => $category) {
$field_name = 'profile_tagging_' . $this->profileTagService
->tagLabelToMachineName($category);
if (isset($form_values[$field_name])) {
$profile_tag_values += $form_values[$field_name];
unset($form_values[$field_name]);
}
}
$form_values[$identifier] = $profile_tag_values;
$form_state
->setValues($form_values);
parent::validateExposed($form, $form_state);
}