tripal_ds.field_formatter.inc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 hook_field_group_format_settings().
  25. * If the group has no format settings, default ones will be added.
  26. * @params Object $group The group object.
  27. * @return Array $form The form element for the format settings.
  28. */
  29. function tripal_ds_field_group_format_settings($group) {
  30. $form = array();
  31. // Add instance_settings.
  32. switch ($group->format_type) {
  33. case 'tripalpane':
  34. $form['label']['#description'] = t('Please enter a label for collapsible elements');
  35. break;
  36. }
  37. return $form;
  38. }
  39. /*
  40. * Implements field_group_pre_render_<format-type>.
  41. * Format type: Tripalpane.
  42. *
  43. * @param $element The field group form element.
  44. * @param $group The Field group object prepared for pre_render.
  45. * @param $form The root element or form.
  46. */
  47. function tripal_ds_field_group_pre_render(&$element, $group, &$form) {
  48. $group_name = $group->group_name;
  49. switch ($group->format_type) {
  50. case 'tripalpane':
  51. $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.'">';
  52. $element['#suffix'] = '</div>';
  53. break;
  54. }
  55. }