Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291123

#type 'table' allow classes on table cells

$
0
0

Problem/Motivation

Due to the structure of the row's columns (tds) in the new #type=>table being the built as the elements within them. It is currently not possible to add #attributes to the table data.

Proposed resolution

Allow more of the theme wrapper's #theme=>table functionality access to the #type=>table. Possible to allow rows to be built with #rows as #theme=>table uses and grab the cell data from that in the form_process_table and other callbacks

API changes

Snippet from: http://drupal.org/node/1876710

<?php
 
// Building Rows with #type=>table (currently)
 
foreach ($entities as $id => $entity) {
    ...

   
// Some table columns containing raw markup.
   
$form['mytable'][$id]['label'] = array(
     
'#markup'=> check_plain($entity->label()),
    );
   
$form['mytable'][$id]['id'] = array(
     
'#markup'=> check_plain($entity->id()),
    );

    ...
  }
?>

<?php
 
// Building Rows with #type=>table (currently)
 
foreach ($entities as $id => $entity) {
    ...

   
// Some table columns containing raw markup.
    // Leave as is.
   
$form['mytable'][$id]['label'] = array(
     
'#markup'=> check_plain($entity->label()),
    );
   
// Allow cell data form #theme=>table
   
$form['mytable'][$id]['id'] = array(
     
'data'=> check_plain($entity->id()),
     
'#attributes'=> array(
       
'class'=> array('table-id-class'),
       
'data-html5-key'=> 'value',
      ),
    );

    ...
  }
?>

#1876718: Allow modules to inject columns into tables more easily
#1876712: [meta] Convert form tables in core to new #type 'table'


Viewing all articles
Browse latest Browse all 291123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>