tripal_ds.field_formatter.inc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Implements hook_field_group_formatter_info().
  4. */
  5. function tripal_ds_field_group_formatter_info() {
  6. return array(
  7. 'form' => array(
  8. 'tripalpane' => array(
  9. 'label' => t('Tripal Pane'),
  10. 'description' => t('This fieldgroup renders the inner content in a Tripal Pane with the title as legend.'),
  11. 'instance_settings' => array('description' => '', 'classes' => '', 'id' => ''),
  12. ),
  13. ),
  14. 'display' => array(
  15. 'tripalpane' => array(
  16. 'label' => t('Tripal Pane'),
  17. 'description' => t('This fieldgroup renders the inner content in a Tripal Pane with the title as legend.'),
  18. 'instance_settings' => array('description' => '', 'classes' => '', 'id' => ''),
  19. ),
  20. ),
  21. );
  22. }
  23. /*
  24. * Implements field_group_pre_render_<format-type>.
  25. * Format type: Tripalpane.
  26. *
  27. * @param $element The field group form element.
  28. * @param $group The Field group object prepared for pre_render.
  29. * @param $form The root element or form.
  30. */
  31. function tripal_ds_field_group_pre_render(&$element, $group, &$form) {
  32. switch ($group->format_type) {
  33. case 'tripalpane':
  34. $group_name = $group->group_name;
  35. $description = $group->format_settings['instance_settings']['description'];
  36. $classes = $group->format_settings['instance_settings']['classes'];
  37. $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.' tripal_pane '.$classes.'"> <span class="field-group-format-title">' . check_plain(t($group->label)) . '</span>';
  38. if (!empty($description)) {
  39. $element['#prefix'] .= '<div class="description">' . $description . '</div>';
  40. }
  41. $element['#suffix'] = '</div>';
  42. break;
  43. }
  44. }