akeeba / fof

Rapid Application Development framework for Joomla!™ 3 and 4
0 stars 0 forks source link

ordering ? #591

Closed Mika17420 closed 8 years ago

Mika17420 commented 8 years ago

Hello, is there any instruction for ordering array in form.profile.xml ? like : <form type="browse" show_header="1" show_filters="0" show_pagination="0" norows_placeholder="COM_NGLIBRARY_COMMON_NORECORDS" ***filter_order="title" order="descending"

nikosdion commented 8 years ago

The ordering is a Model state, not a form attribute. By the time the form is loaded and parsed the Model has already generated its list of items, i.e. the ordering and pagination have already been processed into a SQL query whose results are now being parsed by the form. While you can forcibly set model state variables in fof.xml we don't recommend it since you'd never be able to change the ordering in the form. Instead, you simply need to specialise your Model and set default values for the filter_order and filter_order_Dir model state onBeforeBuildQuery.