Title: Flexible Field &amp; Responsive Table
Last modified: November 17, 2018

---

# Flexible Field & Responsive Table

 *  Resolved [kyleform](https://wordpress.org/support/users/kyleform/)
 * (@kyleform)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/flexible-field-responsive-table/)
 * Hey Johann
 * Plugin works amazingly, great work on it!
 * Was wondering if you can advise on a couple of things:
 * 1. I’m using a responsive bootstrap table and need to pull the header $th into
   the data title within the table body e.g. <td data-title=”$th”>$td</td>
 * 2. Is it possible to use this field within Flexible Content field?
 * Hope you can help, much appreciated.
 * Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Johann Heyne](https://wordpress.org/support/users/jonua/)
 * (@jonua)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/flexible-field-responsive-table/#post-10890882)
 * Hi,
 * 1. The following code should do the trick with the data-title…
 *     ```
       $table = get_field( 'your_table_field_name' );
   
       if ( $table ) {
   
           echo '<table border="0">';
   
               if ( $table['header'] ) {
   
                   echo '<thead>';
   
                       echo '<tr>';
   
                           foreach ( $table['header'] as $th ) {
   
                               echo '<th>';
                                   echo $th['c'];
                               echo '</th>';
                           }
   
                       echo '</tr>';
   
                   echo '</thead>';
               }
   
               echo '<tbody>';
   
                   foreach ( $table['body'] as $tr ) {
   
                       echo '<tr>';
   
                           foreach ( $tr as $key => $td ) {
   
                               echo '<td data-title="' . $table['header'][ $key ]['c'] . '">';
                                   echo $td['c'];
                               echo '</td>';
                           }
   
                       echo '</tr>';
                   }
   
               echo '</tbody>';
   
           echo '</table>';
       }
       ```
   
 * 2. Yes, the table field should work in a Flexible Content field.
 * Cheers,
    Johann
 *  Thread Starter [kyleform](https://wordpress.org/support/users/kyleform/)
 * (@kyleform)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/flexible-field-responsive-table/#post-10890960)
 * Hey Johann
 * Thanks for the response, that worked perfectly, thanks very much for your help
   with that.
 * I changed the get_field to get_sub_field hoping that would work, any ideas on
   what it should actually be?
 * <?php if( get_row_layout() == ‘list’ ): ?>
    <?php $table = the_sub_field( ‘table’);
   if ( $table ) {
 *  Plugin Author [Johann Heyne](https://wordpress.org/support/users/jonua/)
 * (@jonua)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/flexible-field-responsive-table/#post-10891030)
 * `$table = get_sub_field('table');`
 *  Thread Starter [kyleform](https://wordpress.org/support/users/kyleform/)
 * (@kyleform)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/flexible-field-responsive-table/#post-10891535)
 * Thanks for responding again so quickly.
 * The get_sub_field was correct, I just had the wrong field name for the row_layout.
 * All working now, can finally allow clients to make CMS their own tables now, 
   great plugin!!!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Flexible Field & Responsive Table’ is closed to new replies.

 * ![](https://ps.w.org/advanced-custom-fields-table-field/assets/icon-256x256.png?
   rev=1962986)
 * [Table Field Add-on for ACF and SCF](https://wordpress.org/plugins/advanced-custom-fields-table-field/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-custom-fields-table-field/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-custom-fields-table-field/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-custom-fields-table-field/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-custom-fields-table-field/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-custom-fields-table-field/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [kyleform](https://wordpress.org/support/users/kyleform/)
 * Last activity: [7 years, 4 months ago](https://wordpress.org/support/topic/flexible-field-responsive-table/#post-10891535)
 * Status: resolved