forms: tableselect (and the rest)

2 replies [Last post]
frostmar
Offline
Last seen: 6 years 29 weeks ago
Joined: 2011-06-11

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.

craychee
Offline
Last seen: 6 years 35 weeks ago
Joined: 2011-10-19
Could you provide more information?

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?

frostmar
Offline
Last seen: 6 years 29 weeks ago
Joined: 2011-06-11
Hi Craychee, Thanks for

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.

Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:


Loading...
Contact us

Below are the supported keyboard shortcuts for our video player.

space
Start / stop video
shift
Go to next video
shift
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
1...9
Jump to a percentage (2 is 20%, for example)
f
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
$29
1 month
$156
6 months
10% off
$276
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
user
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.