You are here

protected function AjaxColorForm::getColorsByTemperature 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::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 modules/form_api_example/src/Form/AjaxColorForm.php
Form constructor.

File

modules/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'];
}