Editor and multiple select list
Editor and multiple select list
I'm trying to wrap my head around an issue.
I have a MySQL database table for "users" that has a field called "addresses". This address field either has the word "all" or it has a comma delimited list of "id's" from the address table.
I'm trying to figure out how to show this list of addresses so that when a user is added, they can select "all" or select multiple entries with their current entries highlighted?
JS File:
{
"label": "Addresses:",
"name": "table_addresses.id",
"type": "select"
}
PHP File:
Field::inst( 'table_users.addresses' )
->options( 'table_addresses', 'id', 'id' )
and
->leftJoin( 'table_addresses', 'table_addresses.id', '=', 'table_users.addresses' )
This question has an accepted answers - jump to answer
Answers
I think you'll need a custom field type for this - have it very similar to the
checkbox
input type, but with the addition of a radio button for theall
option. The value would then be based on that.Alternatively, you could use the
checkbox
type and have anall
option in the list. Then, on submit (preSubmit
) or in a server-side set formatter, check ifall
was submitted, and reduce the value to just that. You could also add event handlers to the checkboxes to automatically uncheckall
if individual options are selected, and likewise uncheck the individual options ifall
is selected.I suspect the work involved will be fairly similar for these two approaches.
Allan
Problem is that a user can choose from a list of addresses in the hundreds.
The user has a field called "addresses" which is a varChar field with a comma delimited listing of address "ids".
What I want to do is bring up a MULTIPLE select list that has the users current selections highlighted and they can select more or less entries.
Is it possible to cick into a field in the editor update window that would launch another window that would contain the list of addresses and upon closing could update the datatable editor window?
I think the same applies with a multiple select or something more advanced like select2 or selectize.
Yes, but that isn't a feature that is built into Editor. You would need your custom plug-in to open the new layer / window with the options available and then use the API to set the values selected.
Allan
Thanks