Date popup field won't display in tableselect element I am attempting to embed a couple of date fields within a tableselect element, and after trying to use both textfield and date_popup field types, I can't get either to work. Here's my form function using textfields:

function language_dashboard_overview_form($form, &amp;$form_state, $entity) {
  $form = [];
  $options = [];

  $header = [
    'language_locale' =&gt; t('Language Locale'),
    'status' =&gt; t('Status'),
    'staging_url' =&gt; t('Staging URL'),
    'start_date' =&gt; t('Start Date'),
    'end_date' =&gt; t('End Date'),
    'display_title' =&gt; t('Display Title')
  ];

  $translations = $entity-&gt;translations-&gt;data;

  foreach($translations as $locale =&gt; $locale_data) {
    // Get data for all the other fields here
    ...
    // Define start and end date text fields.
    $start_date = new DateTime($entity-&gt;field_locale_publishing_dates[$locale][0]['value']);
    $new_start_date = $start_date-&gt;format('m-d-Y');

    $end_date = new DateTime($entity-&gt;field_locale_publishing_dates[$locale][0]['value2']);
    $new_end_date = $end_date-&gt;format('m-d-Y');

    $start_date_field = [
      'data' =&gt; [
        '#type' =&gt; 'textfield',
        '#size' =&gt; 10,
        '#maxlength' =&gt; 10,
        '#default_value' =&gt; $new_start_date
      ]
    ];

    $end_date_field = [
      'data' =&gt; [
        '#type' =&gt; 'date_popup',
        '#date_format' =&gt; 'm-d-Y',
        '#date_year_range' =&gt; '0:+20',
        '#default_value' =&gt; $new_end_date
        ]
    ];

    $options[] = [
      'language_locale' =&gt; $locale_link,
      'status' =&gt; $status,
      'staging_url' =&gt; $stage_url,
      'start_date' =&gt; $start_date_field,
      'end_date' =&gt; $end_date_field,
      'display_title' =&gt; $title
    ];

  }

  $form['dashboard'] = [
    '#type' =&gt; 'tableselect',
    '#header' =&gt; $header,
    '#options' =&gt; $options
  ];

  $form['submit'] = [
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Submit')
  ];

  return $form;
}


With that, I get the fields, but no default value is filled in (and I've verified that the $start_date_field and $end_date_field  variables have the desired data).

If I try it with date_popup fields like so:

$start_date_field = [
  'data' =&gt; [
    '#type' =&gt; 'date_popup',
    '#date_format' =&gt; 'm-d-Y',
    '#date_year_range' =&gt; '0:+20',
    '#maxlength' =&gt; 10,
    '#default_value' =&gt; $new_start_date
  ]
];

$end_date_field = [
  'data' =&gt; [
    '#type' =&gt; 'date_popup',
    '#size' =&gt; 10,
    '#maxlength' =&gt; 10,
    '#default_value' =&gt; $new_end_date
  ]
];


I get no field at all in those columns. From the multiple items I've read on this, I'm adding the fields correctly to the tableselect. Is there something else I'm missing?

UPDATE: I discovered that for the text field, you use #value instead of #default_value. changing that shows my default date as desired. so the only remaining issue is that I can't get anything to show for a date_popup field.
I still can't get the date_popup element to work in a tableselect element, so I ended up going with text field and the jQuery_ui datepicker (included in core).

  $form['dates'] = [
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('Set Dates'),
    '#collapsible' =&gt; TRUE,
    '#collapsed' =&gt; TRUE
  ];

  $form['dates']['start_date_popup'] = [
    '#type' =&gt; 'date_popup',
    '#title' =&gt; t('Start Date'),
    '#date_format' =&gt; 'Y-m-d',
    '#date_year_range' =&gt; '0:+20',
    '#maxlength' =&gt; 10,
    '#date_label_position' =&gt; 'none',
    '#id' =&gt; 'apply-start-date'
  ];

  $form['dates']['end_date_popup'] = [
    '#type' =&gt; 'date_popup',
    '#title' =&gt; t('End Date'),
    '#date_format' =&gt; 'Y-m-d',
    '#date_year_range' =&gt; '0:+20',
    '#date_label_position' =&gt; 'none',
    '#id' =&gt; 'apply-end-date'
  ];

  $form['dates']['apply_dates_button'] = [
    '#type' =&gt; 'button',
    '#value'=&gt; t('Apply Dates'),
    '#attributes' =&gt; array('id' =&gt; array('apply-dates')),
  ];

...

 'start_date' =&gt; array(
   'data'=&gt; array(
     '#type'=&gt;'textfield',
     '#value'=&gt; $new_start_date,
     '#title' =&gt; 'Start Date',
     '#title_display'=&gt;'invisible',
     '#name'=&gt; 'start_date[' . $locale . ']',
     '#id'=&gt;  'start-date[' . $locale . ']',
     '#attributes' =&gt; array('class' =&gt; array('datepicker')),
     '#size' =&gt; 10,
     '#maxlength' =&gt; 10
   ),
 ),
 'end_date' =&gt; array(
   'data'=&gt; array(
     '#type'=&gt;'textfield',
     '#value'=&gt; $new_end_date,
     '#title' =&gt; 'End Date',
     '#title_display'=&gt;'invisible',
     '#name'=&gt; 'end_date[' . $locale . ']',
     '#id'=&gt; 'end-date[' . $locale . ']',
     '#attributes' =&gt; array('class' =&gt; array('datepicker')),
     '#size' =&gt; 10,
     '#maxlength' =&gt; 10
   ),
 ),


and this JS behavior:

(function ($) {
  Drupal.behaviors.dashboardDatepicker = {
    attach: function (context, settings) {
      // Attach the datepicker to the selected fields.
      $( ".datepicker" ).datepicker({
        dateFormat: "yy-mm-dd",
        changeYear: true,
        yearRange: '-30:+30',
        minDate: '-0',
        showButtonPanel: true
      });

      // Add click handler for apply button.
      $("#apply-dates", context).click(function(event) {
        // Keep the form from being submitted.
        event.preventDefault();
        // Get the dates from the fieldset
        var startDate = $("input[id*='apply-start-date']").val();
        var endDate = $("input[id*='apply-end-date']").val();
        // Get the set of selected checkboxes.
        if(startDate) {
          $("table#locale-table").find("tr.selected").find("input[id*='start-date']").val(startDate);
        }
        if (endDate) {
          $("table#locale-table").find("tr.selected").find("input[id*='end-date']").val(endDate);
        }
      })
    }
  };
}(jQuery));