You are here

function pmorganization_form in Drupal PM (Project Management) 7

Same name and namespace in other branches
  1. 8 pmorganization/pmorganization.module \pmorganization_form()
  2. 7.3 pmorganization/pmorganization.module \pmorganization_form()
  3. 7.2 pmorganization/pmorganization.module \pmorganization_form()

Implements hook_form().

File

pmorganization/pmorganization.module, line 176

Code

function pmorganization_form(&$node) {
  $breadcrumb = array();
  $breadcrumb[] = l(t('Project Management'), 'pm');
  $breadcrumb[] = l(t('Organizations'), 'pm/organizations');
  drupal_set_breadcrumb($breadcrumb);
  $type = node_type_get_type($node);
  $info = field_info_extra_fields('node', 'pmorganization', 'form');
  $form['#attributes']['class'] = 'pmcomponent_node_form';
  $form['group1'] = array(
    '#type' => 'markup',
    '#theme' => 'pm_form_group',
    '#weight' => $info['group1']['weight'],
  );
  $form['group1']['iscustomer'] = array(
    '#type' => 'checkbox',
    '#title' => t('Customer'),
    '#default_value' => isset($node->iscustomer) ? $node->iscustomer : 1,
  );
  $form['group1']['isprovider'] = array(
    '#type' => 'checkbox',
    '#title' => t('Provider'),
    '#default_value' => isset($node->isprovider) ? $node->isprovider : 0,
  );
  $form['group1']['isactive'] = array(
    '#type' => 'checkbox',
    '#title' => t('Active'),
    '#default_value' => isset($node->isactive) ? $node->isactive : 1,
  );
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => check_plain($type->title_label),
    '#required' => TRUE,
    '#default_value' => $node->title,
    '#weight' => $info['title']['weight'],
  );
  $form['group2'] = array(
    '#type' => 'markup',
    '#theme' => 'pm_form_group',
    '#weight' => $info['group2']['weight'],
  );
  $form['group2']['address'] = array(
    '#type' => 'textfield',
    '#title' => t('Address'),
    '#default_value' => isset($node->address) ? $node->address : NULL,
    '#weight' => 1,
  );
  $form['group2']['city'] = array(
    '#type' => 'textfield',
    '#title' => t('City'),
    '#size' => 20,
    '#default_value' => isset($node->city) ? $node->city : NULL,
    '#weight' => 2,
  );
  $form['group2']['provstate'] = array(
    '#type' => 'textfield',
    '#title' => t('Province / State'),
    '#size' => 20,
    '#default_value' => isset($node->provstate) ? $node->provstate : NULL,
    '#weight' => 3,
  );
  $country_list = pm_attributes_bydomain('Country');
  $form['group2']['country'] = array(
    '#type' => 'select',
    '#title' => t('Country'),
    '#options' => $country_list['values'],
    '#default_value' => isset($node->country) ? $node->country : $country_list['default'],
    '#weight' => 4,
  );
  $form['group2']['zip'] = array(
    '#type' => 'textfield',
    '#title' => t('Zip'),
    '#size' => 15,
    '#default_value' => isset($node->zip) ? $node->zip : NULL,
    '#weight' => 5,
  );
  $form['group3'] = array(
    '#type' => 'markup',
    '#theme' => 'pm_form_group',
    '#weight' => $info['group3']['weight'],
  );
  $form['group3']['phone'] = array(
    '#type' => 'textfield',
    '#title' => t('Phone'),
    '#default_value' => isset($node->phone) ? $node->phone : NULL,
  );
  $form['group3']['www'] = array(
    '#type' => 'textfield',
    '#title' => t('WWW'),
    '#size' => 30,
    '#default_value' => isset($node->www) ? $node->www : NULL,
  );
  $form['group3']['email'] = array(
    '#type' => 'textfield',
    '#title' => t('E-mail'),
    '#size' => 30,
    '#default_value' => isset($node->email) ? $node->email : NULL,
  );
  $form['group4'] = array(
    '#type' => 'markup',
    '#theme' => 'pm_form_group',
    '#weight' => $info['group4']['weight'],
  );
  $currency_list = pm_attributes_bydomain('Currency');
  $form['group4']['currency'] = array(
    '#type' => 'select',
    '#title' => t('Currency'),
    '#options' => $currency_list['values'],
    '#default_value' => isset($node->currency) ? $node->currency : $currency_list['default'],
  );
  $pricemode_list = pm_attributes_bydomain('Price mode');
  $form['group4']['pricemode'] = array(
    '#type' => 'select',
    '#title' => t('Price mode'),
    '#default_value' => isset($node->pricemode) ? $node->pricemode : $pricemode_list['default'],
    '#options' => $pricemode_list['values'],
  );
  $form['group4']['price'] = array(
    '#title' => t('Price'),
    '#type' => 'textfield',
    '#size' => 15,
    '#default_value' => isset($node->price) ? $node->price : NULL,
  );
  $languages = language_list('language', TRUE);
  $languages_options = array();
  foreach ($languages as $language_code => $language) {
    $languages_options[$language_code] = $language->name;
  }
  $form['group4']['orglanguage'] = array(
    '#type' => 'select',
    '#title' => t('Language'),
    '#options' => $languages_options,
    '#default_value' => isset($node->orglanguage) ? $node->orglanguage : NULL,
  );
  $form['group4']['taxid'] = array(
    '#type' => 'textfield',
    '#title' => t('Tax ID'),
    '#size' => 20,
    '#default_value' => isset($node->taxid) ? $node->taxid : NULL,
  );

  // Check to see if the body field is still there, if so display it
  $body = field_get_items('pmorganization', $node, 'body');
  if ($body) {
    $form['body_field'] = $body;
  }
  $form['title_old'] = array(
    '#type' => 'hidden',
    '#default_value' => isset($node->title_old) ? $node->title_old : NULL,
  );
  return $form;
}