2

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'); 

And

$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"/> </fields> 

1 Answer 1

2

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.