wordpress-fieldmanager icon indicating copy to clipboard operation
wordpress-fieldmanager copied to clipboard

Select / Chosen type_ahead incompatible with Term datasource

Open danielbachhuber opened this issue 10 years ago • 7 comments

In our Post's term fields, we want to persist the assigned order so the first term assigned to a Post can be considered the "primary" term. Fieldmanager's Select Field with type_ahead and the term data source only works part of the way for this.

Using Chosen, I can assign terms to a post in arbitrary order. The terms are saved to the database correctly. However, because the <select> is built with <option> taxonomy terms in alphabetical order, my specified order is ignored for display (and lost when I save the post).

But, I think the bug is that use_ajax doesn't work with Chosen. For my term data source, I don't want to load all of the terms at once because it's a performance issue.

danielbachhuber avatar Oct 30 '14 17:10 danielbachhuber

Apparently this is why Select2 exists: https://github.com/harvesthq/chosen/issues/79#issuecomment-4312427

danielbachhuber avatar Oct 30 '14 17:10 danielbachhuber

Autocomplete isn't an option because the UI for supporting multiple values isn't that great.

@mboynes @netaustin how would you guys feel about incorporating https://github.com/meltingice/ajax-chosen ?

danielbachhuber avatar Oct 30 '14 18:10 danielbachhuber

Core is going to start using Select2 in places, so it might be better to use that for consistency (unless there's a really good reason to not use it). Regardless, I'm game for changing this.

mboynes avatar Oct 30 '14 18:10 mboynes

so it might be better to use that for consistency (unless there's a really good reason to not use it)

Heh. If you think TinyMCE is bad...

danielbachhuber avatar Oct 30 '14 18:10 danielbachhuber

There is a Chosen implementation in FM Select that was added by me probably close to 2 years ago for a rather specific purpose and fell into disuse. No one that I know is still using it in its current form.

I'd suggest potentially replacing that with this.

bcampeau avatar Oct 30 '14 18:10 bcampeau

Needed to get something together for Fusion, so I put together a Select2 field: https://gist.github.com/danielbachhuber/1293ce788c2398ef6cf5

If you don't mind being bound to a particular library, a dedicated field type for Select2 might make the most sense.

danielbachhuber avatar Nov 26 '14 00:11 danielbachhuber

This is still an issue where the order isgetting changed in chosen field. Are there any plans to fix this issue?

ankitrox avatar Feb 09 '23 15:02 ankitrox