list_test.module 714 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * @file
  4. * Helper module for the List module tests.
  5. */
  6. /**
  7. * Allowed values callback.
  8. */
  9. function list_test_allowed_values_callback($field) {
  10. $values = array(
  11. 'Group 1' => array(
  12. 0 => 'Zero',
  13. ),
  14. 1 => 'One',
  15. 'Group 2' => array(
  16. 2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>',
  17. ),
  18. );
  19. return $values;
  20. }
  21. /**
  22. * An entity-bound allowed values callback.
  23. */
  24. function list_test_dynamic_values_callback($field, $instance, $entity_type, $entity, &$cacheable) {
  25. $cacheable = FALSE;
  26. // We need the values of the entity as keys.
  27. return drupal_map_assoc(array_merge(array($entity->ftlabel), entity_extract_ids($entity_type, $entity)));
  28. }