formtools / core

The Form Tools Core.
https://formtools.org
207 stars 78 forks source link

Two Sided Multi Select UI Control #494

Open darusdp opened 5 years ago

darusdp commented 5 years ago

I'm wanting to add a GUI control that allows user to pick multiple items from one list and add it to another list. This is a control that has a list of Available Items and you Add/Remove to/from the Selected Items list. Common names for the GUI control seem to be List Builder and Two Sided Multi Select.

Additionally, for the items in the Available Items list I want it to be populated via a query to Active Directory for Usernames and Security Groups.

The goal is the user of the form can pick usernames and groups to become members of a new group that the form is collecting information about and will make a submission for another program to pick up an actually create the security group.

My question is, what FormTools component is best suited to do this?

These are potentials that I've found and am researching: Custom Fields, Hooks Manager, Code/Markup fields, Pages module.

Any additional help/code that already does all or much of this would be appreciated.

benkeen commented 5 years ago

Hey @darusdp, if I were tackling this problem myself I actually wouldn't consider any of those other modules you mentioned and create a totally new module. All of those - even the Custom Fields module - are really pretty lightweight: you can do a lot with them, but to do really custom things, a separate module is in order. That's why the Google Maps, TinyMCE Rich text editor, File Upload Field Types are all separate modules.

I won't fib, the code's a bit daunting at first for sure - but I'd maybe look at one of the smaller ones, like the Google Maps field type to see how you can use a module to add your own field type in the FT UI. Feel free to ask any questions if you get stuck.

darusdp commented 5 years ago

What if I wanted to start with a field type of drop down list that has a settings of a text file path\name to populate the choices. Would you still recommend a custom module or would Custom Fields suffice, or would a combination be needed so that the new field type (say DropDownFile) is presented wherever in FT a field type is referenced?

benkeen commented 5 years ago

If we're lucky, you may be able to get away with using the Custom Fields module for that. The question will be Smarty's security settings (Smarty's the templating language used throughout Form Tools and what you use in the Custom Fields Edit Fields tab to generate the markup for the field). There you'll probably need to use this method to load content from the filesystem / a url: https://www.smarty.net/docsv2/en/language.function.fetch.tpl

If you find that that is throwing an error in your logs and not working, try adding this setting to your global/config.php file:

$g_use_smarty_bc = true;

https://docs.formtools.org/userdoc/getting_started/config_file/