You are here

function certificate_form in Certificate 8.3

Same name and namespace in other branches
  1. 6.2 certificate.module \certificate_form()
  2. 6 certificate.module \certificate_form()
  3. 7.3 certificate.module \certificate_form()
  4. 7.2 certificate.module \certificate_form()
  5. 3.x certificate.module \certificate_form()

Certificate node form.

File

./certificate.module, line 11
Certificate module.

Code

function certificate_form($form, &$form_state, $certificate = NULL) {
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => isset($certificate->title) ? $certificate->title : '',
    '#required' => TRUE,
    '#maxlength' => 128,
    '#size' => 60,
  );
  $form['name'] = array(
    '#type' => 'machine_name',
    '#title' => t('Machine name'),
    '#default_value' => isset($certificate->name) ? $certificate->name : '',
    '#required' => TRUE,
    '#maxlength' => 128,
    '#size' => 60,
    '#machine_name' => array(
      'source' => array(
        'title',
      ),
      'exists' => 'certificate_load_single',
    ),
  );
  $form['orientation'] = array(
    '#type' => 'radios',
    '#title' => t('Orientation'),
    '#default_value' => isset($certificate->orientation) ? $certificate->orientation : '',
    '#options' => array(
      'portrait' => t('Portrait'),
      'landscape' => t('Landscape'),
    ),
    '#required' => TRUE,
    '#description' => t('The orientation of the generated certificate.'),
  );
  $form['certificate_tokens'] = array(
    '#type' => 'fieldset',
    '#title' => t('Replacement tokens'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['certificate_tokens']['tokens'] = array(
    '#markup' => theme('token_tree', array(
      'token_types' => array(
        'global',
        'node',
        'user',
        'certificate',
      ),
    )),
  );
  field_attach_form('certificate', $certificate, $form, $form_state);
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}