public function obi__organism::instanceSettingsForm

3.x obi__organism.inc public obi__organism::instanceSettingsForm()

Overrides ChadoField::instanceSettingsForm

See also

TripalField::globalSettingsForm()

File

tripal_chado/includes/TripalFields/obi__organism/obi__organism.inc, line 149

Class

obi__organism

Code

public function instanceSettingsForm() {
  $element = parent::instanceSettingsForm();

  $settings = $this->instance['settings'];
  $element['instructions'] = array(
    '#type' => 'item',
    '#markup' => 'You may rewrite the way this field is presented to the end-user.
        The Rewrite Value field allows you to use tokens to indicate how the
        value should be displayed.  Tokens will be substituted with appriorate
        data from the database.  See the Available tokens list for the
        tokens you may use.'
  );

  $element['field_display_string'] = array(
    '#type' => 'textfield',
    '#title' => 'Rewrite Value',
    '#description' => t('Provide a mixture of text and/or tokens for the format.
          For example: [organism.genus] [organism.species].  When displayed,
          the tokens will be replaced with the actual value.'),
    '#default_value' => $settings['field_display_string'],
  );

  $element['tokens'] = array(
    '#type' => 'fieldset',
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
    '#title' => 'Available Tokens'
  );
  $headers = array('Token', 'Description');
  $rows = array();

  // Here we use the chado_get_tokens rather than the
  // tripal_get_entity_tokens because we can't gurantee that all organisms
  // have entities.
  $tokens = chado_get_tokens('organism');
  foreach ($tokens as $token) {
    $rows[] = array(
      $token['token'],
      $token['description'],
    );
  }

  $table_vars = array(
    'header' => $headers,
    'rows' => $rows,
    'attributes' => array(),
    'sticky' => FALSE,
    'caption' => '',
    'colgroups' => array(),
    'empty' => 'There are no tokens',
  );
  $element['tokens']['list'] = array(
    '#type' => 'item',
    '#markup' => theme_table($table_vars),
  );

  return $element;
}