protected function _initFilterOptions()
    {
        if (!$this->_filterEnabled && !$this->_sortEnabled) {
            return;
        }

        $options = [
            'conditions' => [],
            'order' => []
        ];

        // check filter params
        if (!empty($this->request->getData())) {
            foreach ($this->request->getData() as $field => $value) {
                if (!isset($this->filterFields[$field]) || $value === '') {
                    continue;
                }

                $options = $this->_createFilterFieldOption($field, $value, $options);

                $this->activeFilters[$field] = $value;
            }
        }

        if (isset($this->sortFields[$this->request->getQuery('s')])) {
            $d = 'asc';
            if ($this->request->getQuery('d')) {
                $dir = strtolower($this->request->getQuery('d'));
                if (in_array($dir, ['asc', 'desc'])) {
                    $d = $dir;
                }
            }
            $field = $this->request->getQuery('s');
            $options = $this->_createSortFieldOption($field, $d, $options);
            $this->activeSort[$field] = $d;
        } elseif (!empty($this->defaultSort)) {
            $options = $this->_createSortFieldOption($this->defaultSort['field'], $this->defaultSort['dir'], $options);
            $this->activeSort[$this->defaultSort['field']] = $this->defaultSort['dir'];
        }

        if ($this->request->getQuery('p')) {
            $this->page = $this->request->getQuery('p');
        }

        $this->filterOptions = $options;
    }
protected function _initFilterOptions()
    {
        if (!$this->_filterEnabled && !$this->_sortEnabled) {
            return;
        }

        $options = [
            'conditions' => [],
            'order' => []
        ];

        // check filter params
        if (!empty($this->request->getData())) {
            foreach ($this->request->getData() as $field => $value) {
                if (!isset($this->filterFields[$field]) || $value === '') {
                    continue;
                }

                $options = $this->_createFilterFieldOption($field, $value, $options);

                $this->activeFilters[$field] = $value;
            }
        }

        if (isset($this->sortFields[$this->request->getQuery('s')])) {
            $d = 'asc';
            if ($this->request->getQuery('d')) {
                $dir = strtolower($this->request->getQuery('d'));
                if (in_array($dir, ['asc', 'desc'])) {
                    $d = $dir;
                }
            }
            $field = $this->request->getQuery('s');
            $options = $this->_createSortFieldOption($field, $d, $options);
            $this->activeSort[$field] = $d;
        } elseif (!empty($this->defaultSort)) {
            $options = $this->_createSortFieldOption($this->defaultSort['field'], $this->defaultSort['dir'], $options);
            $this->activeSort[$this->defaultSort['field']] = $this->defaultSort['dir'];
        }

        if ($this->request->getQuery('p')) {
            $this->page = $this->request->getQuery('p');
        }

        $this->filterOptions = $options;
    }
protected function _initFilterOptions ( ) { if ( ! $ this -> _filterEnabled && ! $ this -> _sortEnabled ) { return ; } $ options = [ 'conditions' => [ ] , 'order' => [ ] ] ; // check filter params if ( ! empty ( $ this -> request -> getData ( ) ) ) { foreach ( $ this -> request -> getData ( ) as $ field => $ value ) { if ( ! isset ( $ this -> filterFields [ $ field ] ) || $ value === '' ) { continue ; } $ options = $ this -> _createFilterFieldOption ( $ field , $ value , $ options ) ; $ this -> activeFilters [ $ field ] = $ value ; } } if ( isset ( $ this -> sortFields [ $ this -> request -> getQuery ( 's' ) ] ) ) { $ d = 'asc' ; if ( $ this -> request -> getQuery ( 'd' ) ) { $ dir = strtolower ( $ this -> request -> getQuery ( 'd' ) ) ; if ( in_array ( $ dir , [ 'asc' , 'desc' ] ) ) { $ d = $ dir ; } } $ field = $ this -> request -> getQuery ( 's' ) ; $ options = $ this -> _createSortFieldOption ( $ field , $ d , $ options ) ; $ this -> activeSort [ $ field ] = $ d ; } elseif ( ! empty ( $ this -> defaultSort ) ) { $ options = $ this -> _createSortFieldOption ( $ this -> defaultSort [ 'field' ] , $ this -> defaultSort [ 'dir' ] , $ options ) ; $ this -> activeSort [ $ this -> defaultSort [ 'field' ] ] = $ this -> defaultSort [ 'dir' ] ; } if ( $ this -> request -> getQuery ( 'p' ) ) { $ this -> page = $ this -> request -> getQuery ( 'p' ) ; } $ this -> filterOptions = $ options ; }
Create the filter options that
can be used for model find calls
in the controller.

@return void
Create the filter options that can be used for model find calls in the controller .