You are here

protected function DateList::getElementSelectorInputsOptions in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/DateList.php \Drupal\webform\Plugin\WebformElement\DateList::getElementSelectorInputsOptions()

Get an element's (sub)inputs selectors as options.

Parameters

array $element: An element.

Return value

array An array of element (sub)input selectors.

Overrides WebformElementBase::getElementSelectorInputsOptions

File

src/Plugin/WebformElement/DateList.php, line 72

Class

DateList
Provides a 'datelist' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function getElementSelectorInputsOptions(array $element) {
  $date_parts = isset($element['#date_part_order']) ? $element['#date_part_order'] : [
    'year',
    'month',
    'day',
    'hour',
    'minute',
  ];
  $t_args = [
    '@title' => $this
      ->getAdminLabel($element),
  ];
  $selectors = [
    'day' => (string) $this
      ->t('@title days', $t_args),
    'month' => (string) $this
      ->t('@title months', $t_args),
    'year' => (string) $this
      ->t('@title years', $t_args),
    'hour' => (string) $this
      ->t('@title hours', $t_args),
    'minute' => (string) $this
      ->t('@title minutes', $t_args),
    'second' => (string) $this
      ->t('@title seconds', $t_args),
    'ampm' => (string) $this
      ->t('@title am/pm', $t_args),
  ];
  $selectors = array_intersect_key($selectors, array_combine($date_parts, $date_parts));
  foreach ($selectors as &$selector) {
    $selector .= ' [' . $this
      ->t('Select') . ']';
  }
  return $selectors;
}