Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1700

Joomla! 4.x Coding • Rendering a filter form without using searchtools.

$
0
0
Hello,

I want to render a filter form without using searchtools. I have started with establishing a simple XML file that I put in a correct location (my_component/forms/) with correct name "filter_myview.xml".

Code:

<?xml version="1.0" encoding="utf-8"?><form addfieldprefix="Freedu\Component\Fugo\Site\Field"><fields name="filter"><fieldname="search"type="text"label="My search box"/><fieldname="day_of_week"type="list"label="Day fo week"onchange="this.form.submit();"><option value="1">Monday</option>...<option value="7">Sunday</option></field></fields></form>
I then get the filter form in my view in HtmlView.php

Code:

public function display($template = null) {...$this->filterForm    = $this->get('FilterForm');$this->activeFilters = $this->get('ActiveFilters');...// Call the parent display to display the layout fileparent::display($template);}
Now, if I am using searchtools in my layout file default.php then the filter form gets rendered. This nicely works.

Code:

<?php echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
What I, however, need is to display the filter form without using searchtools (because of a custom layout). So I removed the line with the searchtools and try to render fileds of the filter form using

Code:

<?php echo $this->filterForm->renderField('search'); ?><?php echo $this->filterForm->renderField('day_of_week'); ?>
.

For some reason, the above produces no html. Any hint how to render a filter form without using searchtools? Do I need to implement getFilterForm() in my model myself? With searchtools this is not necessary.

Statistics: Posted by JanoD — Fri Sep 27, 2024 8:24 am



Viewing all articles
Browse latest Browse all 1700

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>