I have lots of custom filters in my J3 front-end components and I'm trying to convert to J4, but always get
0 Call to a member function getcatid() on bool
com_aaprueba/src/Field/filtercatid.php
namespace Sfi\Component\Aaprueba\Site\Field;
defined('_JEXEC') or die();
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\FormField;
class filtercatid extends FormField
{
protected $type = 'filtercatid';
public function getCatid($value)
{
?>
<select
id="filter_catid"
name="filter_catid"
class="form-control js-example-basic-single"
onchange="this.form.submit();"
>
<option value="uno">Uno</option>
<option value="dos">Dos</option>
</select>
< ?php
}
}
src/Model/EspaciosModel.php
protected function populateState($ordering = null, $direction = null)
{
$catid = $this->getUserStateFromRequest($this->context.'.filter.catid', 'filter_catid');
$this->setState('filter.catid', $catid);
parent::populateState('a.espacio', 'ASC');
}
protected function getListQuery()
{
...
src/View/Espacios/HtmlView.php
namespace Sfi\Component\Aaprueba\Site\View\Espacios;
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\MVC\View\GenericDataException;
class HtmlView extends BaseHtmlView
{
protected $state;
protected $items;
protected $pagination;
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
if (\count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode("\n", $errors), 500);
}
return parent::display($tpl);
}
}
tmpl/espacios/default.php
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Form\FormHelper;
?>
...
" method="post" name="adminForm" id="adminForm">
getcatid($this->escape($this->state->get('filter.catid')));
?>
...
***
Please, is there some information about how create custom filters in Joomla 4 without using a xml form?
Thanks, JL