Jump to content

Module: Select Multiple Transfer


ryan
 Share

Recommended Posts

Select Multiple Transfer
 
Multi-selection Inputfield module for ProcessWire using the jquery.uix.multiselect plugin by Yanick Rochon. 
 
This Inputfield provides similar capabilities to asmSelect but in a very different way. The usage of two separate lists may be more convenient when needing to select a large quantity of items. Like asmSelect, it also includes support for sorting of items. Unlike asmSelect, it has a built-in search field for filtering. It can be used anywhere that the other ProcessWire multi-selection inputfields can be used.
 
Download 
 
Important Installation Notes
 
This module is installed like any other, however you will need to take an extra step in order to make it available for page selection. After installing this module, click to your Modules menu and click the core InputfieldPage module to configure it (Modules > Core > Inputfields > Page). Select InputfieldSelectMultipleTransfer as an allowed Inputfield for Page selection, and save. Now you should be able to select it as the Inputfield when editing a Page reference field. For obvious reasons, this Inputfield would only be useful for a Page reference field used to store multiple references. 
 
screenshot.png
 
 
(Note that this video is showing this module in combination with field dependencies and dependent selects (something else brewing for 2.4 but not yet committed to dev). 
  • Like 22
Link to comment
Share on other sites

Great addition! Thanks for your work here.

While we are here, how about making the fieldtype page more dynamic for it's inputfields. I tried to add another inputfield type the other day and it's not possible without hacking the core fieldtype.

Link to comment
Share on other sites

While we are here, how about making the fieldtype page more dynamic for it's inputfields. I tried to add another inputfield type the other day and it's not possible without hacking the core fieldtype.

Which one do you mean? Most Fieldtype modules are paired with an Inputfield by design, and won't work with others. There are a few exceptions that do allow selection of different Inputfields. The Page reference one is a good example. But in order to limit the possibility that someone could break a field, you have to define which Inputfields are allowed from the InputfieldPage module configuration screen. 

Link to comment
Share on other sites

Which one do you mean? Most Fieldtype modules are paired with an Inputfield by design, and won't work with others. There are a few exceptions that do allow selection of different Inputfields. The Page reference one is a good example. But in order to limit the possibility that someone could break a field, you have to define which Inputfields are allowed from the InputfieldPage module configuration screen. 

As I said, for the page fieldt :) Currently it's all hardcoded so I can't create a new inputfield for that field.

Link to comment
Share on other sites

Neat! I have used this UI pattern many times in the past - it'll be awesome to have this ready to just drop into a PW site :-)

To your knowledge, does this UI pattern officially have a name? I usually refer to these as "stock lists" or "swap lists" when talking to clients...

  • Like 1
Link to comment
Share on other sites

As I said, for the page fieldt :) Currently it's all hardcoded so I can't create a new inputfield for that field.

It's actually delegated to InputfieldPage, which is an integral part of FieldtypePage designed primarily for the purpose of exactly what you are talking about: enabling you to select the appropriate Inputfield for your page references. It may look like there are hard coded class names in that module, but they are actually only defaults, fully dynamic and changeable in the module settings. You can add more Inputfields for page selection by going to the InputfieldPage module settings and selecting some more… this step is necessary when installing the module this thread is about. 

To your knowledge, does this UI pattern officially have a name? I usually refer to these as "stock lists" or "swap lists" when talking to clients...

I don't know if there is an official name, but I've always referred to it as a transfer list or a multi-select transfer, as it enables you to transfer items from one to the other. I think your "swap lists" term describes it pretty well too. 

Link to comment
Share on other sites

It's actually delegated to InputfieldPage, which is an integral part of FieldtypePage designed primarily for the purpose of exactly what you are talking about: enabling you to select the appropriate Inputfield for your page references. It may look like there are hard coded class names in that module, but they are actually only defaults, fully dynamic and changeable in the module settings. You can add more Inputfields for page selection by going to the InputfieldPage module settings and selecting some more… this step is necessary when installing the module this thread is about. 

Yeah right. I actually found this after messing around with it. And I though ahh, but now looking again I remember what it was:

In InputfieldPage #129 https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module#L130

 if(in_array($field->inputfield, array('InputfieldPageListSelect', 'InputfieldPageListSelectMultiple'))) {

So I can't create a new PageListSelect inputfield. It gives me error

  • Page 1506 is not valid for select_image

Link to comment
Share on other sites

I'm going to ignore the field completely and jump straight to shouting:

THANK YOU SO MUCH FOR DEPENDENT SELECTS! :D

This is yet another awesome feature I've been silently wishing for for a while - one select field causing a filter on another (which I'm guessing works also for just two regular select fields and doesn't rely on this fieldtype?). Loving how, logically, when the first select field doesn't have a value the second simply isn't shown.

Back to the module - I love that too, but one select filtering another one opens up a new world of possibilities so I'm ecstatic with that by itself :)

  • Like 4
Link to comment
Share on other sites

Any idea why I may be getting a blank box with no available inputs? I have definitely selected the fieldtype and the same settings provide a list using AsmSelect.

post-502-0-58730300-1378470527_thumb.png

I am getting a console error;

Uncaught TypeError: Object [object Object] has no method 'on'

on this line

jquery.uix.multiselect.min.js:66

Link to comment
Share on other sites

Any idea why I may be getting a blank box with no available inputs? I have definitely selected the fieldtype and the same settings provide a list using AsmSelect.

It sounds like you might be running a version of ProcessWire prior to 2.3?

Would it be possible to paginate really long lists? (similar to the Page Tree). Maybe I missed it but will this be shipping with 2.4 or we'll always have to install it ourselves? 

It doesn't look to me like this jQuery multiselect plugin comes with any sort of pagination capabilities. I'm not really sure how they would do it, so kind of doubt that's on their roadmap, but will keep an eye out. 

At the moment, I don't plan to include this module in the core. Though if it's something that we find people will use on more than 30% of sites, then it would be something to consider. 

 if(in_array($field->inputfield, array('InputfieldPageListSelect', 'InputfieldPageListSelectMultiple'))) {
Okay I see what you mean there. Those two modules assume the "parent_id" to mean just the starting point (rather than both starting & ending point), which is why they are called out separately. I didn't think there's be much use for that feature beyond those two modules, but glad to hear I'm wrong–I'm sure I can find some other way to make that configurable. 
  • Like 1
Link to comment
Share on other sites

Is it possible to use this in a method in a module? I tried the following code but got not output and no errors

$test = $this->modules->get('InputfieldSelectMultipleTransfer');
$test->label = $this->_('Test Pages');
$test->columnWidth = 65;
$test->description = $this->_('Select Pages to add.');
Link to comment
Share on other sites

You should be able to use this module from the API side like you've mentioned. The module is built around a jQuery UI plugin called uix.multiselect, so you'll want to make sure that your context includes jQuery UI. Like with all of the selection inputfields, you'll have to add some selectable options:

// add some options
$test->addOption('a', 'Option A');
$test->addOption('b', 'Option B');
$test->addOption('c', 'Option C'); 
// now tell it which ones are already selected
$test->attr('value', array('a', 'c')); 
  • Like 1
Link to comment
Share on other sites

I can't get this to work. Displaying and selecting works fine but as soon as I save I get

Page 1001 is not valid for select_page

I specified the template via a custom selector. As soon as I select a template from the option dropdown the error is gone, but the selected options aren't saved. They aren't showing on the left side but also missing on the right. I'm using latest PW dev. This was switching from a previous single page select to this new transfer inputfield. After saving and moving options multiple times it seems to work again.

Link to comment
Share on other sites

Also recognized that this field doesn't work with the FormSaveReminder listening to form changes. Could you implement a call to make the form changed as soon as a change happens to input you done via script?

I for example had to add this to color picker for FSR to work:

$(this).parent().find('input').val($(this).data('default')).trigger('change');

It's kinda stupid that every inputfield that has special js like updating of fields or hidden fields needs to have this trigger change on input implemented or FSR can't do its work, otherwise the module is kinda pointless :) What you think? Do I now need to hunt down every field/inputtype module that will be created and ask to implement this? Should it be a mandatory implementation we advise? So this sort of save reminder is even possible and reliable.

Link to comment
Share on other sites

In some tests, I was getting the same error (Page 1001 is not valid for select_page) with other Page Multiple fields select types, not just this new module. The issue (I can't find the thread atm), was connected to the template custom selector. IIRC, it was an issue about the status of the pages you want to select via the Page Select. Are they published? are they hidden? etc. Try with a normal page and see if it works. This module has worked for me in dev version as long as those pages are published, not hidden, etc. I hope this makes sense; typed quickly :D

Edit 1:

The forum discussion I referred to is here: 

http://processwire.com/talk/topic/4222-custom-field-to-select-unpublished-pages-selectable-but-doesnt-save-selection/

You also contributed to that discussion :D. Ryan was supposed to fix this and suggested a change (see his post in that thread). I don't know if he merged the changes

Edit 2: 

Hmm. I have tested with a "normal" page and I still get the error. Am confused  :'(

  • Like 1
Link to comment
Share on other sites

For you guys that can't get this working, what is the exact selector string that you are using? Are you combining it with any parent/template settings separate from the selector? I've been using it every day since posting it here, and it's been working well for me on two different sites I've got in development. I'll double check that I don't have any lingering files needing to be committed to dev. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...