You are here

function message_message_render_content_type_edit_form in Message 7

Edit form; Allow selecting a partial.

File

ctools/content_types/message_render.inc, line 45

Code

function message_message_render_content_type_edit_form($form, &$form_state) {
  $conf = $form_state['conf'];
  $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' => $conf['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' => $conf['partials'],
  );
  $form['partials_delta'] = array(
    '#type' => 'select',
    '#title' => t('Partial delta'),
    '#description' => t('The delta to use for partial rendering.'),
    '#default_value' => $conf['partials_delta'],
    '#options' => range(0, 20),
  );
  return $form;
}