function AjaxColorForm::getColorsByTemperature

Same name in other branches
  1. 3.x modules/form_api_example/src/Form/AjaxColorForm.php \Drupal\form_api_example\Form\AjaxColorForm::getColorsByTemperature()
  2. 4.0.x modules/form_api_example/src/Form/AjaxColorForm.php \Drupal\form_api_example\Form\AjaxColorForm::getColorsByTemperature()

Returns colors that correspond with the given temperature.

Parameters

string $temperature: The color temperature for which to return a list of colors. Can be either 'warm' or 'cool'.

Return value

array An associative array of colors that correspond to the given color temperature, suitable to use as form options.

1 call to AjaxColorForm::getColorsByTemperature()
AjaxColorForm::buildForm in form_api_example/src/Form/AjaxColorForm.php

File

form_api_example/src/Form/AjaxColorForm.php, line 103

Class

AjaxColorForm
Implements the ajax demo form controller.

Namespace

Drupal\form_api_example\Form

Code

protected function getColorsByTemperature($temperature) {
    return $this->getColors()[$temperature]['colors'];
}