function options_test_allowed_values_callback

Same name and namespace in other branches
  1. 9 core/modules/options/tests/options_test/options_test.module \options_test_allowed_values_callback()
  2. 8.9.x core/modules/options/tests/options_test/options_test.module \options_test_allowed_values_callback()
  3. 10 core/modules/options/tests/options_test/options_test.module \options_test_allowed_values_callback()

Implements callback_allowed_values_function().

See also

options_allowed_values()

2 string references to 'options_test_allowed_values_callback'
OptionsWidgetsTest::testSelectListMultiple in core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
Tests the 'options_select' widget (multiple select).
OptionsWidgetsTest::testSelectListSingle in core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
Tests the 'options_select' widget (single select).

File

core/modules/options/tests/options_test/options_test.module, line 17

Code

function options_test_allowed_values_callback(FieldStorageDefinitionInterface $definition, ?FieldableEntityInterface $entity = NULL) {
    $values = [
        'Group 1' => [
            0 => 'Zero',
        ],
        1 => 'One',
        'Group 2' => [
            2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>',
        ],
        'More <script>dangerous</script> markup' => [
            3 => 'Three',
        ],
    ];
    return $values;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.