Skip to content

Commit 08d8f19

Browse files
committed
Code suggestion fixes.
1 parent c8439c8 commit 08d8f19

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

web/themes/contrib/civictheme/includes/views.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function civictheme_preprocess_views_exposed_form(array &$variables): void {
163163

164164
if ($field_count == 1) {
165165
// Use inline filter on search and auto pages if a single text field exsits.
166-
if (in_array($view->id(), ['civictheme_search', 'civictheme_automated_list'])) {
166+
if ($view instanceof \Drupal\views\ViewExecutable && in_array($view->id(), ['civictheme_search', 'civictheme_automated_list'])) {
167167
$keyword_field = reset($fields);
168168
if ($keyword_field['#type'] === 'textfield') {
169169
$variables['inline_filter'] = TRUE;
@@ -294,6 +294,8 @@ function _civictheme_preprocess_views_view__results_count(array &$variables): vo
294294
// Load search fields from theme settings.
295295
$setting_keyword_fields = civictheme_get_theme_config_manager()->load('components.search.keyword_fields') ?? '';
296296
if (empty($setting_keyword_fields)) {
297+
// Strip the @keywords token because it exists but won't be populated.
298+
$variables['results_count'] = str_replace('@keywords', '', $variables['results_count']);
297299
return;
298300
}
299301

web/themes/contrib/civictheme/src/Settings/CivicthemeSettingsFormSectionComponents.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,18 @@ public function submitFooter(array &$form, FormStateInterface $form_state): void
603603
);
604604
}
605605

606+
/**
607+
* Submit callback for theme settings form of Search component.
608+
*
609+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
610+
* @SuppressWarnings(PHPMD.StaticAccess)
611+
*/
612+
public function submitSearch(array &$form, FormStateInterface $form_state): void {
613+
$keyword_fields = $form_state->getValue(['components', 'search', 'keyword_fields'], '');
614+
$keyword_fields = CivicthemeUtility::multilineToArray($keyword_fields);
615+
$form_state->setValue(['components', 'search', 'keyword_fields'], $keyword_fields);
616+
}
617+
606618
/**
607619
* Provide a description for a path field.
608620
*

0 commit comments

Comments
 (0)