Problem/Motivation

The search result page has a search form with a search input field whose value is normally set to whatever keyword(s) was searched for. This is helpful as it provides a reminder of what was searched for and allows you to easy alter the search if necessary.

However, this does not work correctly for multi-language sites. If a search is performed from a non-default language, the search field is not set to the keyword(s) of the current search.

Steps to reproduce

1. Configure a site with multiple languages (i.e. English as default language and Spanish as additional langauge)
2. Configure a search api page at the path /search and uncheck the "Use clean URL's" checkbox
3. An English search for "widgets" will render on /search?keys=widgets and "widgets" will be the default value in the search input field on that page.
4. A Spanish search for "widgets" will render on /es/search?keys=widgets but "widgets" will not be the default value in the search input field on that page.

Proposed resolution

Update src/Form/SearchApiPageBlockForm.php to account for an optional language code in the URL when setting the default value of the search input form field.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

RichardDavies created an issue. See original summary.

richarddavies’s picture

Title: Search input value not set for non-default languages » Search form input value not set for non-default languages
richarddavies’s picture

StatusFileSize
new674 bytes

There may be a better solution, but this seems to fix the problem for me.

karlshea made their first commit to this issue’s fork.

  • karlshea committed 6852db2c on 8.x-1.x
    feat: #3189612 Search form input value not set for non-default languages...
karlshea’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.