1

I am creating a small backend component using the helloworld example. So far so good.

It is working fine except when I change the ordering using the listbox:

enter image description here

Nothing happens to list.ordering and list.direction. However, list.fullordering is changed okay.

The field in filter_jbburgstand.xml looks like this:

 <fields name="list">
    <field
        name="fullordering"
        type="list"
        label="JGLOBAL_SORT_BY"
        description="JGLOBAL_SORT_BY"
        onchange="this.form.submit();"
        default="ID ASC"
    >
        <option value="">JGLOBAL_SORT_BY</option>
        <option value="ID ASC">ID oplopend</option>
        <option value="ID DESC">ID aflopend</option>
        <option value="IPadres ASC">IPadres oplopend</option>
        <option value="IPadres DESC">IPadres  aflopend</option>
        <option value="Datum ASC">Datum oplopend</option>
        <option value="Datum DESC">Datum aflopend</option>
        <option value="User ASC">Gebruiker oplopend</option>
        <option value="User DESC">Gebruiker aflopend</option>
    </field>

The populate function looks like this:

protected function populateState($ordering = null, $direction = null)    
{         
    parent::populateState($ordering, $direction);
} 

And the ordering part looks like this:

$orderCol   = $this->state->get('list.ordering', '');
$orderDirn  = $this->state->get('list.direction', '');
// $fullOrder = $this->state->get('list.fullordering', '');
$query->order($db->escape($orderCol) . ' ' . $db->escape($orderDirn));
//echo "<br>".$query."<br>";
return $query;

Why does this happen?

Additional information

It looks like onchange="this.form.submit();" is not being executed when I change to a (new) ordering (in the listbox).

I think the adminForm should be reloaded and that is not happening.

3
  • 2
    Did you follow the guide here? docs.joomla.org/J3.x:Developing_an_MVC_Component/… This is for a front-end ("site") form, not backend ("administrator"). Suggest having a read over this: docs.joomla.org/J3.x:Developing_an_MVC_Component/… If that does not help, more details about your view would be helpful - does your view incorporate an order[], task and boxchecked hidden input fields, as well as a form.token? – Grant G Aug 29 '20 at 23:50
  • 1
    @Pol Welcome to JSE and thank you for contributing. Please take our tour. Also, if you want our community to know that your name is Jan, please do not add it to the bottom of your posts ("signoffs" will be edited out of posts because they do not benefit researchers). Instead, please edit your profile to tell us a much as you like about who you are and your experience with Joomla / web development. I see that you are using escape() on the column name in the order() call; I recommend calling $db->qn() so that the string is appropriately quote-wrapped for all database drivers. – mickmackusa Aug 30 '20 at 0:04
  • Did you add the column/field names in your model to $config['filter_fields'] = array( ? – pe7er Sep 1 '20 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.