I like to unset my search filter that is saved in the user state.
I have a search input with id filter_search
This is the code to save the filter.

$context = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $context);

Now In another function I would like to unset this filter_search state.
How Do I do this?

I already tried this:

$session = Factory::getSession();
$session->clear('.filter.search', 'filter_search');


$this->setState('filter.search', "");

But my input field stays filled.

This is my filter_customers.xml

<fields name="filter">
        <field name="search" type="text" hint="COM_MYDESTINY_SEARCH_FILTER_SUBMIT" label="COM_USERS_FILTER_SEARCH_DESC" class="js-stools-search-string uk-search-input"/>

1 Answer 1


The solution I found was

$app->setUserState($this->context . '.filter.search', "");

The context can be changed so you can also change filters from different models

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.