getUserStateFromRequest issue

13 views
Skip to first unread message

j-guy

unread,
Nov 29, 2017, 7:20:55 PM11/29/17
to Joomla! General Development
Hi, 

I've got a custom component with a search page that includes simple text filters and multi-select list filters.    The search and pagination work fine when I use a simple text filters like filter_text_search.   The search works with multi-select items as well.   The pagination fails when the multi-select filters are used because the model to retrieve the stored multi-select values.    Any thoughts?

My JModelList::populateState stores the values like below.   
$text_search = $app->getUserStateFromRequest($this->context.'.filter.text_search', 'filter_text_search');
$this->setState('filter.text_search', $text_search);

$array_search = $app->getUserStateFromRequest($this->context .'.filter.array_search', 'filter_array_search');
$this->setState('filter.array_search', $array_search);

I've tested this calling getUserStateFromRequest with $app and $this. Just as a test, I modified my form to return the multi-select filter in a string using the javascript join function.  I was surprised to find it had the same issue.   

 I'm not sure how getStoreId would effect this problem but I tried some variations

                $id.= ':'. serialize($this->getState('filter.array_search'));

$array_search = $this->getState('filter.array_search');
if (is_array($array_search )){
$id.= ':' . implode(',', $array_search );
}
else {
$id.= ':' .  $array_search ;
}
                
Reply all
Reply to author
Forward
0 new messages