Save a select multiple list by user input order

41 views
Skip to first unread message

Joaquim Nogueira

unread,
Aug 22, 2016, 12:12:46 PM8/22/16
to Joomla! General Development
JOOMLA 3.5.1

I'm building a component/module and i need to save the multiple authors in the order that user introduces in the administrator. But with the JFormFieldList and using the JHtml::_('formbehavior.chosen', 'select'); it loads and saves in alphabetic order not in user input order.

Is there a simple way to do this?

brian teeman

unread,
Aug 22, 2016, 1:29:02 PM8/22/16
to Joomla! General Development


On Monday, 22 August 2016 17:12:46 UTC+1, Joaquim Nogueira wrote:
JOOMLA 3.5.1


WHY!!!! Always use the latest version

Randy Carey

unread,
Aug 23, 2016, 10:01:46 PM8/23/16
to Joomla! General Development
I was struggling with the same type of issue.  I recently solved it through the new field type subform which was just introduced in Joomla 3.6.x.  https://docs.joomla.org/Subform_form_field_type 

In your case create a subform field that contains a field for selecting an author.  Make the field "multiple" so that the user can select one or more authors for any field.  The content manager can drag-and-drop the various items within this subfield into any order you want, and that order is retained.  Thje value for this field is stored within the database as a JSON string, so when you extract it, you will need to decode it back into a series of values. I just started to use this new field type in a client project and I am finding multiple uses for it as well as it being a usability hit with my client.
Reply all
Reply to author
Forward
0 new messages