Datepicker Form

0

I have created a module in Drupal 8 that creates a block with its respective form, everything works fine, but I can not put a datepicker field, I have tried several things but they do not work.

 $form['date'] = [
            '#type' => 'date_range',
            '#title' => $this->t('Date'),
            '#date_date_format' => $date_format,
            '#date_time_format' => $time_format,
            '#description' => date($date_format, time()),
            '#default_value' => DrupalDateTime::createFromTimestamp(time()),
        ];
    
asked by Fen Dev 16.01.2017 в 12:47
source

1 answer

0

According to the Drupal forms API, you should put #type to datepicker :

$form['date'] = array(
  '#type' => 'datepicker',
  '#date_format' => 'd/m/Y',
);

Drupal Reference

    
answered by 16.01.2017 в 12:51