Robin S Posted December 14, 2021 Posted December 14, 2021 Select Once Per Table Adds a setting to "Select", "Page (Select)" and "Page (Autocomplete Single)" columns in a ProFields Table field so that each option can only be selected once per table. Requires the ProFields Table module. There could be a number of situations where this module might be useful, but perhaps the primary situation is when you want to store extra information for pages that are selected in a Page Reference field. So instead of using a Page Reference field like this... ...you could use a ProFields Table field together with Select Once Per Table to store extra information for each selected page like this... The module ensures that pages/options that are already selected in the Table field are disabled as you add new rows or edit existing rows. Configuration To enable the module for any "Select", "Page (Select)" or "Page (Autocomplete Single)" column in your Table field, edit the column settings and add selectOnce=1. https://github.com/Toutouwai/SelectOncePerTablehttps://processwire.com/modules/select-once-per-table/ 9 2
dotnetic Posted December 15, 2021 Posted December 15, 2021 Here is an article where I did something similar for a client project "Disable select option if already selected in another select box". In my case it is only a JavaScript without settings and it works for every select, not only in Pro fields table. 2
ceberlin Posted December 15, 2021 Posted December 15, 2021 great idea. I could really use it. In my case I have an Autocomplete instead of a Select for the page reference (too many targets) and unfortunately, there double entries are still selectable. But intercepting here, might be another level of complexity. But I might soon find a use case where this fits in well. Thanks for the module! 1
Robin S Posted December 15, 2021 Author Posted December 15, 2021 4 hours ago, ceberlin said: In my case I have an Autocomplete instead of a Select for the page reference (too many targets) and unfortunately, there double entries are still selectable. I've added support for "Page (Autocomplete Single)" columns in v0.2.0. 3
MarkE Posted December 15, 2021 Posted December 15, 2021 1 hour ago, Robin S said: I've added support for "Page (Autocomplete Single)" columns in v0.2.0. Just what I need for a current project. Brill! 1
MarkE Posted December 16, 2021 Posted December 16, 2021 Page (Autocomplete Single) works very nicely. Thanks @Robin S. Just one thought - is it possible to add 'selectOnce' to the existing hints under the settings box - no worries if not, just "a nice to have". 1
Robin S Posted December 16, 2021 Author Posted December 16, 2021 11 hours ago, MarkE said: Just one thought - is it possible to add 'selectOnce' to the existing hints under the settings box Added in v0.2.1 1
ceberlin Posted December 17, 2021 Posted December 17, 2021 That's a little bit like Christmas for me. So useful! An additional reminder under the PW hints for the field might guarantee that this handy option is remembered when the module is active? • validate: Validates that Pages in value matches your selector on page save.• selectOnce=1: Each option can only be selected once per table
Robin S Posted December 19, 2021 Author Posted December 19, 2021 On 12/18/2021 at 5:39 AM, ceberlin said: An additional reminder under the PW hints for the field might guarantee that this handy option is remembered when the module is active? See here:
Pete Posted January 26, 2022 Posted January 26, 2022 There's an issue with autocomplete - until you save you can still enter the same thing in multiple rows. Once saved they are indeed removed from the autocomplete the next time you try to add them but not before saving.
Robin S Posted January 27, 2022 Author Posted January 27, 2022 5 hours ago, Pete said: There's an issue with autocomplete - until you save you can still enter the same thing in multiple rows. I can't reproduce that. The column configuration I used for testing: Screencast: Is pagination turned on for your Table field by any chance? Can you provide steps for a basic test case where the problem occurs? 1
Pete Posted January 27, 2022 Posted January 27, 2022 You're right, it is working. I think I fell foul of having changed the table schema and sometimes it can get itself a bit mixed up. When I stripped out some extra settings from when my first column was a different fieldtype and re-saved it started behaving itself just fine. Thanks for checking!
Pete Posted January 27, 2022 Posted January 27, 2022 Aha, I managed to get this to happen again. Step 1: delete two PageAutoComplete entries and save the page - the empty rows remain (I really wish empty rows wouldn't get saved but that's another story): Step 2: Typing into the fields in the two existing empty rows you can enter the same value twice (so below I just entered the Parkland Resort extra into the first of the two empty rows, and am able to add it again in the second of the empty rows) It respects the once-per-table setting when you add a new row, but not for empty existing rows. I do wonder if another belt-and-braces solution here is to simply check for and delete duplicate rows on save too? 1
Robin S Posted January 27, 2022 Author Posted January 27, 2022 11 hours ago, Pete said: Aha, I managed to get this to happen again. Thanks, should be fixed in v0.2.2 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now