function chado_add_admin_form_set_title

2.x chado_add_admin_form_set_title(&$form, &$form_state, $details)

Generic "Set Node Title" sub-form for setting the title of any chado node


$form: The Drupal form array into which the property form elements will be added

$form_state: The corresponding form_state array for the form

$details: An array defining details used by this form. Required keys that are always required: -module: the name of the module implementing the node. For example, for features the module is tripal_feature. -options: an array of quick-choice options to supply to the user. The key should be the token and the value should be a human-readable description of the option -content_type: the name of the content type. Defaults to module name. Optional keys include: -fieldset_title: the title to use for the fieldset. Defaults to "Set Page Title". -default_option: the default format to use which matches one of those in $details['options'] -custom_tokens: an array of custom tokens that follow the same format as those generated by chado_node_generate_tokens().

Related topics

11 calls to chado_add_admin_form_set_title()
tripal_analysis_admin in tripal_analysis/includes/
Administration page callbacks for the Tripal Analysis module
tripal_contact_admin in tripal_contact/includes/
Administrative settings form
tripal_example_admin in tripal_example/includes/
Administrative settings form
tripal_featuremap_admin in tripal_featuremap/includes/
Administrative settings form
tripal_feature_admin in tripal_feature/includes/
Feature Settings page

... See full list


tripal_core/api/, line 245
Contains API functions to set titles and paths for all chado nodes


function chado_add_admin_form_set_title(&$form, &$form_state, $details) {

  // Get Node Info
  if (isset($details['module'])) {
    $node_info = call_user_func($details['module'] . '_node_info');
    $chado_node_api = $node_info[$details['content_type']]['chado_node_api'];
  else {
    "Set Titles API: When calling chado_add_admin_form_set_title, you \$details array must include 'module' => [name of your module] in order to pull out all the information provided in your implementation of hook_node_info"

  // Defaults
  $details['fieldset_title'] = (isset($details['fieldset_title'])) ? $details['fieldset_title'] : 'Set Page Titles';
  $details['additional_instructions'] = (isset($details['additional_instructions'])) ? $details['additional_instructions'] : '';
  $details['custom_tokens'] = (isset($details['custom_tokens'])) ? $details['custom_tokens'] : array();
  $details['content_type'] = (isset($details['content_type'])) ? $details['content_type'] : $details['module'];

  $tokens = array();
  if (empty($tokens)) {
    $tokens = chado_node_generate_tokens($chado_node_api['base_table']);
  $tokens = array_merge($tokens, $details['custom_tokens']);
  $token_list = chado_node_format_tokens($tokens);
  $details['default_option'] = (isset($details['default_option'])) ? $details['default_option'] : chado_node_get_title_format($details['content_type'], $tokens);

  $msg = t(
  'Each synced %singular must have a unique page title, however, %plural may have the
      same name if they are of different types or from different organisms. Therefore,
      we must be sure that the page titles can uniquely identify the %singular being viewed.
      Select an option below that will uniquely identify all %plural on your site.'
    . $details['additional_instructions'], 
  array('%singular' => $chado_node_api['record_type_title']['singular'],
    '%plural' => $chado_node_api['record_type_title']['plural'])
  $form['set_titles'] = array(
    '#type' => 'fieldset',
    '#title' => t($details['fieldset_title']),
    '#description' => $msg,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#prefix' => "<div id='set_titles-fieldset'>",
    '#suffix' => '</div>',

  $form['set_titles']['content_type'] = array(
    '#type' => 'hidden',
    '#value' => $node_info[$details['content_type']]['base'],

  $details['options']['custom'] = 'Custom: See the text field below.';
  $form['set_titles']['title_option'] = array(
    '#title' => t('%singular Page Titles', array('%singular' => $chado_node_api['record_type_title']['singular'])),
    '#type' => 'radios',
    '#description' => t("Choose a title type from the list above that is
      guaranteed to be unique for all %plural. If in doubt it is safest to choose
      the 'Unique Constaint' option as that guarantees uniqueness.", 
    array('%plural' => $chado_node_api['record_type_title']['plural'])),
    '#required' => FALSE,
    '#options' => $details['options'],
    '#default_value' => (isset($details['options'][$details['default_option']])) ? $details['default_option'] : 'custom',

  $form['set_titles']['title_format_variable'] = array(
    '#type' => 'hidden',
    '#value' => $details['module'] . '_title_format'

  $form['set_titles']['custom_title'] = array(
    '#type' => 'textarea',
    '#title' => 'Custom Page Title',
    '#description' => 'You may rearrange elements in this text box to customize the page
      titles. The available tokens are listed below. You can separate or include any text
      between the tokens. <strong>Important: be sure that whatever you choose
      will always be unique even considering future data that may be added. If in doubt,
      please select the unique constraint title option above.</strong>',
    '#default_value' => $details['default_option'],
    '#rows' => 1

  $form['set_titles']['token_display'] = array(
    '#type' => 'fieldset',
    '#title' => 'Available Tokens',
    '#description' => 'Copy the token and paste it into the "Custom Page Title" text field above.',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE

  $form['set_titles']['token_display']['content'] = array(
    '#type' => 'item',
    '#markup' => $token_list

  $form['set_titles']['tokens'] = array(
    '#type' => 'hidden',
    '#value' => serialize($tokens)

  $form['set_titles']['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Set Titles',
    '#validate' => array('chado_add_admin_form_set_title_form_validate'),
    '#submit' => array('chado_add_admin_form_set_title_form_submit')