SmartDateCustomFormatter is pulling value from wrong setting.

Created on 13 June 2024, 6 months ago
Updated 8 July 2024, 5 months ago

Problem/Motivation

I"m trying to set a different on the hour time, but the on time defaults to time.


    // Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateCustomFormatter
    // Line 66

    $form['time_format'] = [
      '#type' => 'textfield',
      '#title' => $this->t('PHP Time Format'),
      '#description' => $this->t('The PHP date code to use for formatting times.'),
      '#default_value' => $this->getSetting('time_format'),
    ];

    $form['time_hour_format'] = [
      '#type' => 'textfield',
      '#title' => $this->t('PHP Time Format - on the hour'),
      '#description' => $this->t('The PHP date code to use for formatting times that fall on the hour. Examples might be 2pm or 14h. Leave this blank to always use the standard format specified above.'),
      '#default_value' => $this->getSetting('time_format'),
    ];

Steps to reproduce

On the hour time keeps reverting to default time format.

Proposed resolution

Set time_hour_format field correctly. '#default_value' => $this->getSetting('time_hour_format') instead of '#default_value' => $this->getSetting('time_format'')

    $form['time_hour_format'] = [
      '#type' => 'textfield',
      '#title' => $this->t('PHP Time Format - on the hour'),
      '#description' => $this->t('The PHP date code to use for formatting times that fall on the hour. Examples might be 2pm or 14h. Leave this blank to always use the standard format specified above.'),
      '#default_value' => $this->getSetting('time_hour_format'),
    ];
πŸ› Bug report
Status

Fixed

Version

4.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jalite1991

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024