LostKobrakai

InputfieldChosenSelect

Recommended Posts

Just thinking out loud if you are looking for something to do :)

As if I didn't talk about other modules on the todo list in another thread. But actually it's not an inputfield which is bound to be used with FieldtypePage, as this states in the module declaration.

... extends InputfieldSelectMultiple implements InputfieldHasArrayValue

The module does add itself automatically to be usable with pages in the settings of FieldtypePage, so maybe it's only missing it's entry in FieldtypeOptions' settings. I'll test this tomorrow and if it's that way, I'll add the addition/removal to install() and uninstall().

  • Like 2

Share this post


Link to post
Share on other sites

I've just checked, the module does work out of the box with FieldtypeOptions, so nothing to do for me :)

Edit: At least for the "Interface".

Seems like Ryan did not include an option for adding new options from the inputfield by now, like it's for FieldtypePage. The thing I don't like about including it myself is, that I can't really guess a value for the field, while this would give the ability to change the wording afterwards, even if it's only a typo. Maybe we should first ask Ryan if he could implement a standartised way for auto values, then it would be easy to include a "add option" field like for pages. I'll open a feature request over on github.

  • Like 3

Share this post


Link to post
Share on other sites

Just a quick note - there seems to be a bit of an issue on touch screens. Not sure if it is something related to your module, or the chosen library itself, but the first time I tap on the field, it automatically selects and adds the first page to the list of selected items. After that I can tap again and no selections are made. 

This happened to me on Chrome on iOS, but I haven't tested other browsers/devices.

Share this post


Link to post
Share on other sites

Chosen is disabled on iPhone, iPod Touch, and Android mobile devices (more information).

That the statement on the projects page. I've just tested it on safari and it's not loading, so maybe chrome in iOS  isn't properly detected as mobile browser.

Share this post


Link to post
Share on other sites

Interesting - chosen actually works on tablet sized devices, but is disabled on phone sized ones. The issue I mentioned above doesn't seem to be an issue on Safari on tablets.

Having this not work on phone sized devices though is quite a problem - the selection of existing pages works well enough, but not being able to add new ones is a deal breaker for me. 

I haven't tried it yet, but there is this fork of chosen that claims to work with mobile devices:

https://github.com/rafalenden/chosen

Maybe your module could fallback to ASM select with a textarea (for creating new pages) if on phone sized? Or maybe some other option - there has to be a cleaner way :)

Not sure the best option yet - will think about it more later.

Share this post


Link to post
Share on other sites

If chosen is not working is should report this back, so I should be able to just unhide the textarea to allow adding of pages.

Edit: Just pushed a commit to add this. Now you can at least add pages. Will take a look at the fork later.

  • Like 1

Share this post


Link to post
Share on other sites

I've just added a new version of the module on the dev branch. A request for a single select inputfield powered by the chosen library came up on github. So I implemented it, which does mean the current inputfield is renamed to …SelectMultiple. I still want to add some more fitting styles, but it would also be nice to have some feedback if everything is still working for you guys, before I merge it to master.

  • Like 2

Share this post


Link to post
Share on other sites

I love this field type. A user of mine needs to select several pages from 100s and the tree traversal wasn't quick enough to be practical. One thing we do miss iS the ability to reorder chosen pages like the regular page select.

Is that on the horizon?

Share this post


Link to post
Share on other sites

If you mean drag and drop, that's already implemented.

Oh cool. I hadn't realised. Rushes off to check it....

Share this post


Link to post
Share on other sites

The drag and drop reordering works lovely. Thanks for letting me know.

Can I just chip in some thoughts? 

  • This is just a personal preference but I wonder if the selected items should matched the display of the normal Page Select results.
    IE stacked vertically with 100% width, trash icon and colored background. Then again, your way fits more selections into a smaller space.|
     
  • I wonder if the drag and drop could be refined a little. When I drag a selected page left or right, I see a dotted line which I don't think is necessary. It's also only 70% height of the field too which makes it look like a mistake. It's probably a part of the original jQuery setup?
     
  • Chrome has an annoying habit of trying to auto-fill the results and bringing up a selection of 'helpful' results.

But really, thanks for taking time to make this. It's a really cool field and my users will love it.

Share this post


Link to post
Share on other sites

One more thing. This may not be part of your Module but when I save a page with the Chosen Select field, I get some weird formatting. See top left of screen and specifically the UL ID of:

<ul id="notices" class="ui-widget">
<li class="ui-state-highlight NoticeMessage ui-priority-secondary NoticeDebug"><a class="notice-remove" href="#"><i class="fa fa-times-circle"></i></a><i class="fa fa-gear"></i> Session: Change: Company_Selector_2</li>

post-1166-0-04386400-1427724109_thumb.pn

I think the width here needs to be 100% and not 100px?

.ui-state-highlight.ui-state-highlight {
  top: 0;
  background: rgb(240,240,240);
  margin: 3px 5px 3px 0;
  padding: 0;
  border: 1px dotted gray;
  width: 100px;
  height: 19px;
}

Share this post


Link to post
Share on other sites

This thing is supposed to be the ghost element while drag-and-droping a tag. Congrats jQuery UI... I'll see if I can namespace this thing somehow. 

Edit: it's fixed for the dev branch. Will push it to master as soon as I've included a defaultAdminTheme.css as well. 

  • Like 1

Share this post


Link to post
Share on other sites

Is it possible to allow users to add pages by typing in something but still only show the same pages as before in the drop down?

For example I have "foo" and "bar" as pages which get shown in the dropdown. Now user1 types "lorem". So a page called "lorem" get created.

Now user1 creates a new page. The drop down should only show "foo" and "bar" and NOT "lorem".

Maybe if "lorem" would be "hidden" the drop down could exclude it... Could you add this as an option? Like: "make auto-created pages hidden to prevent them from appearing in the list"?

Share this post


Link to post
Share on other sites

While the new page is in the dropdown it should be grayed out and unselectable as it's already selected. So what's the problem with showing it? I don't think there's an easy option to to hide them as the chosen library is automatically build from a multiselect input which does not have any modifiers. I've tried to add destinct styling to new pages before and found no good way to do this.

Share this post


Link to post
Share on other sites

What I want to archive is that you have like ten constant suggestions but still can add your own tags which should be saved but not appear in the drop down list. Maybe I have to change it a little than :/

Or is there another way to archive that?

Share this post


Link to post
Share on other sites

Maybe the easiest way to solve this would be with some custom js logic, as your subselection needs to be in another selectfield as your saved values (which include added pages). Otherwise I'd look into other libraries as chosen is really trying to act like real selectfields.

Share this post


Link to post
Share on other sites

Made a small update so that InputfieldChosenSelectMultiple now respects the "Allow pages to be added" setting. Without it one cannot add tags anymore.

  • Like 3

Share this post


Link to post
Share on other sites

Thanks for this great module. It works perfectly together with my FieldtypeSelectExtOption.

I use it also with new Core Module Options. Is there any chance to provide the ability to add options via the Inputfield, like adding pages if used together with FieldtypePage? I know it is more on Ryans side to provide this in his Module. Maybe there is a possibility of an approach from your side too?

Share this post


Link to post
Share on other sites

Exactly what I am looking for. :) Since new page will be created by method renderAddable() in class InputfieldPage and not in FieldtypePage it would be maybe more on the Inputfield side to offer this feature. Especially in case of InputfieldChosenSelect it would be great to have it.

Share this post


Link to post
Share on other sites

I'm probably overlooking something basic but I can't get this to work. I've located the plugin in the modules directory - installed it on the modules page (no strikeout line any more through Input Chosen Select and Input Chosen Select Multiple). Then when I go to add a new field - but Input Chosen Multiple doesn't appear in the select box for field type.  What am I missing?  (ProcessWire 2.6.1) - jquery-1.10.2.min.js located in templates>scripts

Thanks in advance (feeling very stupid)

Share this post


Link to post
Share on other sites

It should normally add itself in the list of usable page inputfields, but could you please take a look at the module configuration of InputfieldPage if those two are in the list or not.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://gitlab.com/baumrock/RockFinder/tree/master
       
      Changelog
      180817, v1.0.6, support for joining multiple finders 180810, v1.0.5, basic support for options fields 180528, v1.0.4, add custom select statement option 180516, change sql query method, bump version to 1.0.0 180515, multilang bugfix 180513, beta release <180513, preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/
    • By OLSA
      Hello for all,
      ConfigurationForm fieldtype module is one my experiment from 2016.
      Main target to build this module was to store multiple setup and configuration values in just 1 field and avoid to use 1 db table to store just single "number of items on page", or another db table to store "layout type" etc. Thanks to JSON formatted storage this module can help you to reduce number of PW native fields in project, save DB space, and reduce number of queries at front-end.
      Install and setup:
      Download (at the bottom ), unzip and install like any other PW module (site/modules/...). Create some filed using this type of field (ConfigurationForm Fieldtype) Go to field setup Input tab and drag some subfields to container area (demo). Set "Name" and other params for subfields Save and place field to templates ("Action tab") How to use it:
      In my case, I use it to store setup and configurations values, but also for contact details, small content blocks... (eg. "widgets").
      Basic usage example:
      ConfigForm fieldtype "setup" has subfields:
      "limit", type select, option values: 5, 10, 15, 20
      "sort", type select, option values: "-date", "date",  "-sort", "sort"
      // get page children (items) $limit = isset($page->setup->limit) ? $page->setup->limit : 10; $sort = isset($page->setup->sort) ? $page->setup->sort : '-sort'; $items = $page->children("limit=$limit, sort=$sort");  
      Screenshots:


       
      Notes:
      Provide option to search inside subfields Provide multilanguage inputs for text and textarea field types Provide option for different field layout per-template basis Do not place/use field type "Button" or "File input" because it won't works. Please read README file for more details and examples Module use JSON format to store values. Text and textarea field types are multilanguage compatible, but please note that main target for this module was to store setup values and small content blocks and save DB space. Search part inside JSON is still a relatively new in MySQL (>=5.77) and that's on you how and for what to use this module.
      Thanks:
      Initial point for this fieldtype was jQuery plugin FormBuiled and thanks to Kevin Chappel for this plugin.
      In field type "link" I use javascript part from @marcostoll module and thanks to him for that part.
      Download:
      FieldtypeConfigForm.zip
      Edit: 14. August 2018. please delete/uninstall previously downloaded zip
      Regards.
         
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://gitlab.com/baumrock/RockPdf
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
    • By Thomas Diroll
      Hi guys I'm relatively new to PW and just finished developing a page for a client. I was able to include all necessary functionality using the core fieldtypes but now I it seems that I need to extend them with a custom one. What I need is a simple button, that copies the absolute url (frontend not PW-backend) of the page which is currently edited to the clipboard. As this feature is only needed inside a specific template, I tend to use a custom fieldtype which provides this feature. I've been looking inside the core modules code (eg. FieldtypeCheckbox.module) but I don't really get the structure of it and how its rendered to the admin page. I also didn't find a lot of tutorials covering custom fieldtypes.
      Maybe some of you could give me some tips on how to write a basic custom fieldtype that renders a button which copies the value of
      page->httpUrl() to the clipboard using JS. Thanks!
    • By bernhard
      Some of you might have followed the development of this module here: https://processwire.com/talk/topic/15524-previewdiscussion-rockdatatables/ . It is the successor of "RockDataTables" and requires RockFinder to get the data for the grid easily and efficiently. It uses the open source part of agGrid for grid rendering.
       
      WHY?
      ProcessWire is awesome for creating all kinds of custom backend applications, but where it is not so awesome in my opinion is when it comes to listing this data. Of course we have the built in page lister and we have ListerPro, but none of that solutions is capable of properly displaying large amounts of data, for example lists of revenues, aggregations, quick and easy sorts by the user, instant filter and those kind of features. RockGrid to the rescue 😉 
       
      Features/Highlights:
      100k+ rows Instant (client side) filter, search, sort (different sort based on data type, eg "lower/greater than" for numbers, "contains" for strings) extendable via plugins (available plugins at the moment: fullscreen, csv export, reload, batch-processing of data, column sum/statistics, row selection) all the agGrid features (cell renderers, cell styling, pagination, column grouping etc) vanilla javascript, backend and frontend support (though not all plugins are working on the frontend yet and I don't plan to support it as long as I don't need it myself)  
      Limitations:
      While there is an option to retrieve data via AJAX the actual processing of the grid (displaying, filtering, sorting) is done on the client side, meaning that you can get into troubles when handling really large datasets of several thousands of rows. agGrid should be one of the most performant grid options in the world (see the official example page with a 100k row example) and does a lot to prevent problems (such as virtual row rendering), but you should always have this limitation in mind as this is a major difference to the available lister options that do not have this limitation.
      Currently it only supports AdminThemeUikit and I don't plan to support any other admin theme.
       
      Download: https://gitlab.com/baumrock/RockGrid
      Installation: https://gitlab.com/baumrock/RockGrid/wikis/Installation
      Quikckstart: https://gitlab.com/baumrock/RockGrid/wikis/quickstart
      Further instructions: https://gitlab.com/baumrock/RockGrid/wikis/quickstart#further-instructions
       
      Module status: alpha, License: MIT
      Note that every installation and uninstallation sends an anonymous google analytics event to my google analytics account. If you don't want that feel free to remove the appropriate lines of code before installation/uninstallation.
       
      Contribute:
      You can contribute to the development of this and other modules or just say thank you by
      testing, reporting issues and making PRs at gitlab liking this post buying me a drink: paypal.me/baumrock/5 liking my facebook page: facebook.com/baumrock hiring me for pw work: baumrock.com  
      Support: Please note that this module might not be as easy and plug&play as many other modules. It needs a good understanding of agGrid (and JavaScript in general) and it likely needs some looks into the code to get all the options. Please understand that I can not provide free support for every request here in the forum. I try to answer all questions that might also help others or that might improve the module but for individual requests I offer paid support for 60€ per hour.
       
      Changelog
      180730 support subdir installations 180711 bugfix (naming issue) 180630 alpha realease  
      Use Cases / Examples:
      Colored grid cells, Icons, Links etc. The Grid also has a "batcher" feature built in that helps communicating with the server via AJAX and managing resource intensive tasks in batches:

      Filters, PW panel links and instant reload on panel close:

      You can combine the grid with a chart library like I did with the (outdated) RockDataTables module: