views_plugin_row_fields.inc

  1. 3.x plugins/views_plugin_row_fields.inc
  2. 2.x plugins/views_plugin_row_fields.inc

Contains the base row style plugin.

File

plugins/views_plugin_row_fields.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains the base row style plugin.
  5. */
  6. /**
  7. * The basic 'fields' row plugin
  8. *
  9. * This displays fields one after another, giving options for inline
  10. * or not.
  11. *
  12. * @ingroup views_row_plugins
  13. */
  14. class views_plugin_row_fields extends views_plugin_row {
  15. function option_definition() {
  16. $options = parent::option_definition();
  17. $options['inline'] = array('default' => array());
  18. $options['separator'] = array('default' => '');
  19. $options['hide_empty'] = array('default' => FALSE);
  20. return $options;
  21. }
  22. /**
  23. * Provide a form for setting options.
  24. */
  25. function options_form(&$form, &$form_state) {
  26. $options = $this->display->handler->get_field_labels();
  27. if (empty($this->options['inline'])) {
  28. $this->options['inline'] = array();
  29. }
  30. $form['inline'] = array(
  31. '#type' => 'checkboxes',
  32. '#title' => t('Inline fields'),
  33. '#options' => $options,
  34. '#default_value' => $this->options['inline'],
  35. '#description' => t('Inline fields will be displayed next to each other rather than one after another.'),
  36. );
  37. $form['separator'] = array(
  38. '#title' => t('Separator'),
  39. '#type' => 'textfield',
  40. '#size' => 10,
  41. '#default_value' => isset($this->options['separator']) ? $this->options['separator'] : '',
  42. '#description' => t('The separator may be placed between inline fields to keep them from squishing up next to each other. You can use HTML in this field.'),
  43. );
  44. $form['hide_empty'] = array(
  45. '#type' => 'checkbox',
  46. '#title' => t('Hide empty fields'),
  47. '#default_value' => $this->options['hide_empty'],
  48. '#description' => t('Do not display fields, labels or markup for fields that are empty.'),
  49. );
  50. }
  51. /**
  52. * Perform any necessary changes to the form values prior to storage.
  53. * There is no need for this function to actually store the data.
  54. */
  55. function options_submit($form, &$form_state) {
  56. $form_state['values']['row_options']['inline'] = array_filter($form_state['values']['row_options']['inline']);
  57. }
  58. }