I haven't been able to look at the latest patch in #991454: Add element #type table (with tableselect and tabledrag support) but I promise to review it once I have the time, in case it hasn't gone in until then.

For now, here is a rather simple patch that adds the ability to retain attributes such as colspan for cells.
It definitely works, because I'm currently testing this with the 7.x-2.x branch of Clock module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler’s picture

FileSize
953 bytes

And the patch...

sun’s picture

hm. That's definitely the simplest approach, but it duplicates the #attributes of the cell content markup, in case the cell's content is "simple"; i.e., $element[$first][$second] contains the cell content directly (no further sub-keys).

That might be acceptable, but perhaps not. It's definitely not acceptable when considering #attributes['id']...

An alternative approach would be to support a custom #wrapper_attributes or #cell_attributes property.

tstoeckler’s picture

FileSize
953 bytes

While #wrapper_attributes definitely sounds nice, I'd say let's go with a simple approach that works for this now.
Introducing #cell_attributes. I also went for #row_attributes for consistency. The risk of confusion/duplication isn't very big for rows, but I thought why not. I'll reroll without that, though, if you don't like it.

I tested the basic functionality and it works.

tstoeckler’s picture

Just to make that clear, I think #wrapper_attributes is the right direction in the long run, I just don't know how to implement it in a generic fashion. Or of course, we could just call what I called #row_attributes and #cell_attributes #wrapper_attributes, I don't know. I'm not really 100% comfy with the Form/Render API so I'll basically roll whatever you say...

tstoeckler’s picture

Status: Needs review » Needs work

Wow, I just realized I uploaded the same patch twice...
Don't know if I can still find the right one, otherwise I'll have to re-code. Anyway, needs work.

tstoeckler’s picture

Assigned: Unassigned » tstoeckler

Also, assigning so that I don't forget.

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
1.18 KB

Here we go.

tstoeckler’s picture

FileSize
1.18 KB

Retesting