data['locations'][$this->data("location")] = $this->data("location");?>{data/jsonen:locations}I'm just not sure how I would modify this so that it works with multi-select set to Yes."> Dynamically add options to a multi-select field - Forums

Forums

Dynamically add options to a multi-select field

megana 05 Mar, 2019
I love how the dropdowns work in CF6, how I can either click the arrow to see the full list of options or just start typing and it will show me potential matches.

I would like to have a dropdown list where, if the user types something that has no match on the list, it is added to the top or bottom of the list for them to choose. I'm not sure if this would be done with the Event tab of the dropdown field or if some custom JS would be required. This would be for a dropdown with multi-select set to Yes, which I think makes it a bit more complicated.

Can anyone point me in the right direction?

EDIT: I just realized the dropdown field I was looking at has an autocomplete and that's why the functionality is so cool. I think that makes it still more complicated to do what I'm trying to do...

EDIT 2: I successfully modified the autocomplete to do this, but it only works if multi-select is set to No.

Here is the Custom Code I'm using:
<?php
$this->data['locations'] = $this->get("read_data11");
$this->data['locations'][$this->data("location")] = $this->data("location");
?>
{data/jsonen:locations}
I'm just not sure how I would modify this so that it works with multi-select set to Yes.
healyhatman 05 Mar, 2019
That's not possible with vanilla CF, you'd have to code that in yourself.
megana 05 Mar, 2019
I thought I might, I was hoping to get some guidance. The auto complete is kind of stumping me because I'm not sure how to debug what that event is doing or what the data that it gets from the form looks like, when a multi-select is involved.

Setting aside the part about adding things to the list based on what the user types, is a multi-select with autocomplete even possible?
megana 05 Mar, 2019
I thought I might, I was hoping to get some guidance. The auto complete is kind of stumping me because I'm not sure how to debug what that event is doing or what the data that it gets from the form looks like, when a multi-select is involved.

Setting aside the part about adding things to the list based on what the user types, is a multi-select with autocomplete even possible?
Max_admin 08 Mar, 2019
Hi megana,

I understand you want the dropdown to "auto complete" on typing, and the ability to add new options, both are possible, but the 2nd is not implemented and can be added as a new feature to the next update!

The auto complete feature has a demo form, did you check it ?

Best regards
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
megana 05 Apr, 2019
Hi Max,

Very slow response on my part, but yes I checked out the demo and I have the auto complete working great and also the ability to add new options, however if I set Multi Select to Yes then the auto complete no longer works. The three things I'm trying to have work together on a single dropdown:
1) Auto complete
2) Add new options
3) Multi Select

I've got the first two working, but can't figure out how to add the third. As soon as I set Multi Select to Yes and add brackets after my field's name, the autocomplete won't work anymore. Any tips?

Thanks,
-Megan
Max_admin 07 Apr, 2019
Hi Megan,

You need to adjust the "Read data" of the auto completer correctly in that case, with "multi select" the value passed is an array, I did not try it myself before but you need to adjust the code!

Best regrads
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.