tripal_ds.field_formatter.inc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. 'format_types' => array('open', 'collapsible', 'collapsed'),
  12. 'instance_settings' => array('description' => '', 'classes' => '', 'id' => ''),
  13. 'default_formatter' => 'collapsible',
  14. ),
  15. ),
  16. 'display' => array(
  17. 'tripalpane' => array(
  18. 'label' => t('Tripal Pane'),
  19. 'description' => t('This fieldgroup renders the inner content in a Tripal Pane with the title as legend.'),
  20. 'format_types' => array('open', 'collapsible', 'collapsed'),
  21. 'default_formatter' => 'collapsible',
  22. 'instance_settings' => array('description' => '', 'classes' => '', 'id' => ''),
  23. ),
  24. ),
  25. );
  26. }
  27. /**
  28. * Implements hook_field_group_format_settings().
  29. * If the group has no format settings, default ones will be added.
  30. * @params Object $group The group object.
  31. * @return Array $form The form element for the format settings.
  32. */
  33. function tripal_ds_field_group_format_settings($group) {
  34. $form = array();
  35. // Add instance_settings.
  36. switch ($group->format_type) {
  37. case 'tripalpane':
  38. $form['label']['#description'] = t('Please enter a label for collapsible elements');
  39. break;
  40. }
  41. return $form;
  42. }
  43. /*
  44. * Implements field_group_pre_render_<format-type>.
  45. * Format type: Tripalpane.
  46. *
  47. * @param $element The field group form element.
  48. * @param $group The Field group object prepared for pre_render.
  49. * @param $form The root element or form.
  50. */
  51. function tripal_ds_field_group_pre_render(&$element, $group, &$form) {
  52. $group_name = $group->group_name;
  53. switch ($group->format_type) {
  54. case 'tripalpane':
  55. $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.'">';
  56. $element['#suffix'] = '</div>';
  57. break;
  58. }
  59. }