You are here

function sweaver_type_form in Sweaver 7

Same name and namespace in other branches
  1. 6 plugins/sweaver_plugin_editor/sweaver_plugin_editor.admin.inc \sweaver_type_form()

Type new/edit form.

File

plugins/sweaver_plugin_editor/sweaver_plugin_editor.admin.inc, line 669
Administrative functions for Sweaver.

Code

function sweaver_type_form(&$form, $type = NULL) {
  if (empty($type)) {
    $type = new stdClass();
    $type->name = '';
    $type->description = '';
    $type->type_options = array();
    $type->export_type = 1;
  }
  if (!isset($type->oid)) {
    $type->oid = NULL;
  }
  $form['#object_type'] = 'type';
  $form['check_name'] = array(
    '#type' => 'value',
    '#value' => $type->export_type == 1 && !isset($type->oid) ? TRUE : FALSE,
  );
  $form['oid'] = array(
    '#type' => 'value',
    '#value' => $type->oid,
  );
  $form['name'] = array(
    '#title' => t('Machine name'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#default_value' => $type->name,
    '#description' => t('The machine-readable name of this type. This name must contain only lowercase letters, numbers, underscores or hyphens and must be unique.'),
  );
  $form['description'] = array(
    '#title' => t('Description'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#default_value' => $type->description,
    '#description' => t('Description of this type only to be used for administration forms.'),
  );
  $type_options = sweaver_ctools_object_list('property', -1, TRUE);
  sweaver_export_check_serialized_keys($type);
  $form['type_options'] = array(
    '#title' => t('Options'),
    '#type' => 'checkboxes',
    '#options' => $type_options,
    '#default_value' => $type->type_options,
    '#description' => t('Options for this type.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#submit' => array(
      'sweaver_type_form_submit',
    ),
  );
  return $form;
}