How can I use the field_ui_table element in a custom module? How can I use the field_ui_table element in a custom module? Is it even possible to use it?

The following code doesn't show anything.

$form['menu_builder']['list1'] = array(
  '#type' =&gt; 'field_ui_table',
  '#header' =&gt; $header,
  '#options' =&gt; $options,
  '#empty' =&gt; t('No content available.'),
  '#attributes'=&gt;array('id'=&gt;'menu-builder-table'),
);
Looking at theme_field_ui_table(), the function that renders the field_ui_table element, and field_ui_display_overview_form(), a form builder that uses that form element, I can say that:


Neither #options nor #rows is used from the rendering function
Leaving out those two element attributes, the code you shown contains just the declaration of the table; it still needs to define the elements to render in the table, which the render function expects to be a list of fields.


The code adding the fields to be listed as rows of the table is quite complex. 

  foreach ($instances as $name =&gt; $instance) {
    $field = field_info_field($instance['field_name']);
    $display = $instance['display'][$view_mode];
    $table[$name] = array(
      '#attributes' =&gt; array(
        'class' =&gt; array(
          'draggable',
          'tabledrag-leaf',
        ),
      ),
      '#row_type' =&gt; 'field',
      '#region_callback' =&gt; 'field_ui_display_overview_row_region',
      '#js_settings' =&gt; array(
        'rowHandler' =&gt; 'field',
        'defaultFormatter' =&gt; $field_types[$field['type']]['default_formatter'],
      ),
      'human_name' =&gt; array(
        '#markup' =&gt; check_plain($instance['label']),
      ),
      'weight' =&gt; array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Weight for @title', array(
          '@title' =&gt; $instance['label'],
        )),
        '#title_display' =&gt; 'invisible',
        '#default_value' =&gt; $display['weight'],
        '#size' =&gt; 3,
        '#attributes' =&gt; array(
          'class' =&gt; array(
            'field-weight',
          ),
        ),
      ),
      'parent_wrapper' =&gt; array(
        'parent' =&gt; array(
          '#type' =&gt; 'select',
          '#title' =&gt; t('Label display for @title', array(
            '@title' =&gt; $instance['label'],
          )),
          '#title_display' =&gt; 'invisible',
          '#options' =&gt; $table['#parent_options'],
          '#empty_value' =&gt; '',
          '#attributes' =&gt; array(
            'class' =&gt; array(
              'field-parent',
            ),
          ),
          '#parents' =&gt; array(
            'fields',
            $name,
            'parent',
          ),
        ),
        'hidden_name' =&gt; array(
          '#type' =&gt; 'hidden',
          '#default_value' =&gt; $name,
          '#attributes' =&gt; array(
            'class' =&gt; array(
              'field-name',
            ),
          ),
        ),
      ),
      'label' =&gt; array(
        '#type' =&gt; 'select',
        '#title' =&gt; t('Label display for @title', array(
          '@title' =&gt; $instance['label'],
        )),
        '#title_display' =&gt; 'invisible',
        '#options' =&gt; $field_label_options,
        '#default_value' =&gt; $display['label'],
      ),
    );

    // ...

  }


Yes, it is possible to use that form element, using the correct data. Since it has been written for a very specific purpose, it's easier to write code for a custom form element, if the task is not showing a table with the same degree of complexity. If the code is then used for a single form, it's even easier to create a custom table in a form.