You are here

protected function AjaxColorForm::getColors in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 form_api_example/src/Form/AjaxColorForm.php \Drupal\form_api_example\Form\AjaxColorForm::getColors()

Returns an array of colors grouped by color temperature.

Return value

array An associative array of color data, keyed by color temperature.

1 call to AjaxColorForm::getColors()
AjaxColorForm::getColorTemperatures in modules/form_api_example/src/Form/AjaxColorForm.php
Returns a list of color temperatures.

File

modules/form_api_example/src/Form/AjaxColorForm.php, line 126

Class

AjaxColorForm
Implements the ajax demo form controller.

Namespace

Drupal\form_api_example\Form

Code

protected function getColors() {
  return [
    'warm' => [
      'name' => $this
        ->t('Warm'),
      'colors' => [
        'red' => $this
          ->t('Red'),
        'orange' => $this
          ->t('Orange'),
        'yellow' => $this
          ->t('Yellow'),
      ],
    ],
    'cool' => [
      'name' => $this
        ->t('Cool'),
      'colors' => [
        'blue' => $this
          ->t('Blue'),
        'purple' => $this
          ->t('Purple'),
        'green' => $this
          ->t('Green'),
      ],
    ],
  ];
}