select.inc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @file
  4. * Plugin definition for synonyms friendly select behavior.
  5. */
  6. $plugin = array(
  7. 'title' => t('Select'),
  8. 'description' => t('Synonyms friendly select'),
  9. 'settings form callback' => 'synonyms_behavior_select_settings_form',
  10. 'interface' => 'SelectSynonymsBehavior',
  11. );
  12. /**
  13. * Settings form for select behavior.
  14. */
  15. function synonyms_behavior_select_settings_form($form, &$form_state, $settings) {
  16. static $is_first_time = TRUE;
  17. $element = array();
  18. $element['wording'] = array(
  19. '#type' => 'textfield',
  20. '#title' => t('Select wording'),
  21. '#default_value' => isset($settings['wording']) ? $settings['wording'] : '@synonym',
  22. '#description' => t('Specify with what wording the synonyms should be placed in the select form element. You may use: <ul><li><em>@synonym</em> to denote value of the synonym</li><li><em>@term</em> to denote term name</li><li><em>@field_name</em> to denote lowercase label of the field from where the synonym originates</li></ul>'),
  23. '#required' => TRUE,
  24. );
  25. if (!$is_first_time) {
  26. // Remove the description, if the element is created more than once on the
  27. // same form. Otherwise the whole form looks too clumsy.
  28. unset($element['wording']['#description']);
  29. }
  30. $is_first_time = FALSE;
  31. return $element;
  32. }