You are here

function relation_class_form in Subform 5

hook_form

File

./relation_class.module, line 88
CRUD, and manage relation_classes and relation_class lists

Code

function relation_class_form(&$node) {
  drupal_set_html_head(theme('stylesheet_import', base_path() . drupal_get_path('module', 'subform') . '/subform.css'), "module");
  drupal_set_html_head(theme('stylesheet_import', base_path() . drupal_get_path('module', 'subform') . '/relation_class.css'), "module");
  $form = array(
    'title' => array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#required' => TRUE,
      '#default_value' => $node->title,
      '#weight' => -5,
    ),
    'sides' => array(
      '#type' => 'fapi_table',
      'rows' => array(
        array(
          // first row
          array(
            // first cell
            'left_node_type' => array(
              '#type' => 'select',
              '#title' => t('Node Type'),
              '#default_value' => $node->left_node_type,
              '#options' => node_get_types(),
              '#required' => TRUE,
            ),
          ),
          array(
            // second cell
            'right_node_type' => array(
              '#type' => 'select',
              '#title' => t('Node Type'),
              '#default_value' => $node->right_node_type,
              '#options' => node_get_types(),
              '#required' => TRUE,
            ),
          ),
        ),
        array(
          // second row
          array(
            // first cell
            'left_node_cardinality' => array(
              '#type' => 'textfield',
              '#title' => t('Cardinality'),
              '#default_value' => $node->left_node_cardinality,
              '#required' => TRUE,
            ),
          ),
          array(
            // second cell
            'right_node_cardinality' => array(
              '#type' => 'textfield',
              '#title' => t('Cardinality'),
              '#default_value' => $node->right_node_cardinality,
              '#required' => TRUE,
            ),
          ),
        ),
        array(
          // third row
          array(
            // first cell
            'unique_instances' => array(
              '#type' => 'checkbox',
              '#title' => 'Prevent duplicate relation instances?',
              '#default_value' => isset($node->unique_instances) ? $node->unique_instances : true,
            ),
          ),
          array(),
        ),
      ),
    ),
  );
  return $form;
}