daily_form

Definition

daily_form(&$node, &$param)
daily/daily_container.inc, line 49

Description

Implementation of hook_form(): Build a node editing form for node type Daily Container.

Related topics

Namesort iconDescription
Daily Container node type functionsAll functions which define the node type Daily Container.
Hook implementationsFunctions that implement standard Drupal hooks.

Code

<?php
function daily_form(&$node, &$param) {
  $vid = variable_get("daily_vocabulary", 0);
  $query = db_query("SELECT td.tid, td.name FROM {term_data} td WHERE td.vid = %d ORDER BY td.name", $vid);

  while ($db_record = db_fetch_object($query)) {
    $options[$db_record->tid] = $db_record->name;
  }

  # PHP5 complains if no options are present
  if (!count($options)) {
    $options[0] = '<none>';
  }

  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $node->title,
    '#size' => 60,
    '#maxlength' => 128,
    '#description' => NULL,
    '#attributes' => NULL,
    '#required' => TRUE,
  );

  $form['tid'] = array(
    '#type' => 'select',
    '#title' => t("Vocabulary term"),
    '#default_value' => $node->tid,
    '#options' => $options,
    '#description' => t("The daily item class"),
    '#extra' => 0,
    '#multiple' => FALSE,
    '#required' => TRUE,
  );

  $form["nr"] = array(
    '#type' => 'textfield',
    '#title' => t("Position"),
    '#default_value' => $node->nr,
    '#size' => 3,
    '#maxlength' => 5,
    '#description' => t("The position within the class. Use -1 for the last item, -2 for the last-but-one item, etc; use 1 for the first item, 2 for the second item, etc; use 0 for a random item refreshed once a day."),
    '#attributes' => NULL,
    '#required' => TRUE,
  );

  return $form;
}
?>