You are here

function merci_hours_form in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

Generates the merci hours editing form.

See also

merci_hours_form_submit().

merci_hours_form_submit_delete().

File

merci_hours/includes/entity.ui.inc, line 14
Work calendar editing UI.

Code

function merci_hours_form($form, &$form_state, $merci_hours, $op = 'edit') {
  if ($op == 'clone') {
    $merci_hours->label .= ' (cloned)';
    $merci_hours->name .= '_clone';
  }
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Label'),
    '#default_value' => $merci_hours->label,
    '#maxlength' => 255,
    '#required' => TRUE,
  );
  $form['name'] = array(
    '#type' => 'machine_name',
    '#default_value' => $merci_hours->name,
    '#disabled' => $merci_hours
      ->isLocked() && $op != 'clone',
    '#maxlength' => 32,
    '#machine_name' => array(
      'exists' => 'merci_hours_load',
      'source' => array(
        'label',
      ),
    ),
  );
  $form['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#default_value' => $merci_hours->description,
  );
  field_attach_form('merci_hours', $merci_hours, $form, $form_state);
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 40,
  );
  if (!$merci_hours
    ->isLocked() && $op != 'add' && $op != 'clone') {
    $form['actions']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#weight' => 45,
      '#limit_validation_errors' => array(),
      '#submit' => array(
        'merci_hours_form_submit_delete',
      ),
    );
  }
  return $form;
}