You are here

protected function DateList::getElementSelectorInputsOptions in YAML Form 8

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 YamlFormElementBase::getElementSelectorInputsOptions

File

src/Plugin/YamlFormElement/DateList.php, line 53

Class

DateList
Provides a 'datelist' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

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' => $this
      ->t('@title days', $t_args),
    'month' => $this
      ->t('@title months', $t_args),
    'year' => $this
      ->t('@title years', $t_args),
    'hour' => $this
      ->t('@title hours', $t_args),
    'minute' => $this
      ->t('@title minutes', $t_args),
    'second' => $this
      ->t('@title seconds', $t_args),
    'ampm' => $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;
}