You are here

function message_handler_field_message_render::options_form in Message 7

Same name and namespace in other branches
  1. 6 includes/message_handler_field_message_render.inc \message_handler_field_message_render::options_form()

Provide form to select a field name to render.

Overrides views_handler_field::options_form

File

includes/views/handlers/message_handler_field_message_render.inc, line 29
Contains the message field handler.

Class

message_handler_field_message_render
Views field handler for rendering a message.

Code

function options_form(&$form, &$form_state) {
  $options = array();
  foreach (field_info_instances('message_type') as $bundle => $instances) {
    foreach ($instances as $field_name => $instance) {
      if (!empty($options[$field_name])) {
        continue;
      }
      $field = field_info_field($field_name);
      if (!in_array($field['type'], array(
        'text_long',
        'text',
      ))) {
        continue;
      }
      $options[$field_name] = $instance['label'];
    }
  }

  // Get all the text fields attached to a message-type.
  $form['field_name'] = array(
    '#type' => 'select',
    '#title' => t('Field name'),
    '#description' => t('Select the field name to render.'),
    '#options' => $options,
    '#default_value' => $this->options['field_name'],
    '#required' => TRUE,
  );

  // Get all the text fields attached to a message-type.
  $form['partials'] = array(
    '#type' => 'checkbox',
    '#title' => t('Partial'),
    '#description' => t('Render only a single delta out of the whole message (in case it is separated in multiple deltas).'),
    '#default_value' => $this->options['partials'],
  );
  $form['partials_delta'] = array(
    '#type' => 'select',
    '#title' => t('Partial delta'),
    '#description' => t('The delta to use for partial rendering.'),
    '#default_value' => $this->options['partials_delta'],
    '#options' => range(0, 20),
    '#dependency' => array(
      'edit-options-partials' => array(
        TRUE,
      ),
    ),
  );
  parent::options_form($form, $form_state);
}