forms: tableselect (and the rest)
I have tables in my module that I want to handle in the same way as the admin/content screen or the admin/people screen. That is to say, I want it to have custom sections to filter the rows like "SHOW ONLY USERS WHERE" or "SHOW ONLY ITEMS WHERE" and a bespoke action section like "UPDATE OPTIONS"
Being a good drupaler, I asked myself WWCD? (what would core do?). Preparing the actual table using tableselect is pretty straight forward, it's constructing the top bits that are giving me problems. I'm finding Core a little impenetrable. Sure, I could work it out given the time. But I'm hoping that someone out there can point me in the direction of a friendly tutorial.
Any Suggestions?
Cheers,
Martin.
Hi Craychee,
Thanks for getting back to me. I don't use Views as I'm writing a module. tableselect is part of the Form API. It does something similar to Views but I need more flexibility as I am accessing tables that I have created as part of the same module.
I solved the problem in the end. Only one form is needed but there will be more than one select button. Core stores values in a global variable called $_SESSION which is an array. It creates a named element which, in turn, may hold sub-arrays. These can then be picked up after the filter has been submitted and the database query amended accordingly.
I'd never hack core. Too much grief would be experienced later down the road. I have been tempted to write the odd patch for myself and re-apply it but I've always found a way round the problem in the end.
Thanks for the link though. It will make some nice, bed-time reading ;)
Martin.
Hey Martin,
I am probably missing what you are trying to accomplish here but it sounds like you just need a View to create the table of users with these filters and views bulk operations to perform actions.
You mention Core. Are you saying that you are looking to Drupal Core for coding standards? (In which case, look no further than: http://drupal.org/coding-standards.) You cross your heart, hope to die that you are not threatening to hack core, right?