Back to ListModel class

Method getFilterForm

public \Joomla\CMS\Form\Form|null
getFilterForm
(mixed $data = array(), mixed $loadData = true)
Get the filter form
Parameters
  • array $data data
  • bool $loadData load current data
Returns
  • \Joomla\CMS\Form\Form|null The \JForm object or null if the form can't be found
Since
  • 3.2
Class: ListModel
Project: Joomla

Method getFilterForm - Source code

/**
 * Get the filter form
 *
 * @param   array    $data      data
 * @param   boolean  $loadData  load current data
 *
 * @return  Form|null  The \JForm object or null if the form can't be found
 *
 * @since   3.2
 */
public function getFilterForm($data = array(), $loadData = true)
{
    // Try to locate the filter form automatically. Example: ContentModelArticles => "filter_articles"
    if (empty($this->filterFormName)) {
        $classNameParts = explode('Model', \get_called_class());
        if (\count($classNameParts) >= 2) {
            $this->filterFormName = 'filter_' . str_replace('\\', '', strtolower($classNameParts[1]));
        }
    }
    if (empty($this->filterFormName)) {
        return null;
    }
    try {
        // Get the form.
        return $this->loadForm($this->context . '.filter', $this->filterFormName, array('control' => '', 'load_data' => $loadData));
    } catch (\RuntimeException $e) {
    }
    return null;
}