You are here

function simplemeta_form in Simple Meta 7.2

SimpleMeta entity form callback.

See also

entity_form()

1 string reference to 'simplemeta_form'
simplemeta_entity_info in ./simplemeta.module
Implements hook_entity_info().

File

./simplemeta.admin.inc, line 13
Admin UI, callbacks and helper functions.

Code

function simplemeta_form($form, &$form_state, $meta, $op, $type = NULL) {
  $form['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Path'),
    '#description' => t('% may be used as placeholder for system paths, for example, news/archive/%'),
    '#default_value' => $meta->path,
    '#required' => TRUE,
  );
  $form['language'] = array(
    '#type' => 'select',
    '#title' => t('Language'),
    '#options' => _simplemeta_language_list(),
    '#default_value' => $meta->language,
  );
  $form['data'] = array(
    '#tree' => TRUE,
  );

  // Meta title.
  $form['data']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#maxlength' => 255,
    '#default_value' => isset($meta->data['title']) ? $meta->data['title'] : '',
  );

  // Meta description.
  $form['data']['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#default_value' => isset($meta->data['description']) ? $meta->data['description'] : '',
  );
  $form['data']['keywords'] = array(
    '#type' => 'textfield',
    '#title' => t('Keywords'),
    '#description' => t('Comma-separated list of keywords.'),
    '#maxlength' => 255,
    '#default_value' => isset($meta->data['keywords']) ? $meta->data['keywords'] : '',
  );
  $form['actions'] = array(
    '#type' => 'actions',
    '#weight' => 400,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#validate' => array(
      'simplemeta_form_validate_save',
    ),
    '#submit' => array(
      'simplemeta_form_submit_save',
    ),
  );
  if (!empty($meta->sid)) {
    $form['actions']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#suffix' => l(t('Cancel'), 'admin/content/simplemeta'),
      '#submit' => array(
        'simplemeta_form_submit_delete',
      ),
      '#weight' => 45,
    );
  }

  // We append the validate handler to #validate in case a form callback_wrapper
  // is used to add validate handlers earlier.
  $form['#attributes']['class'][] = str_replace('_', '-', __FUNCTION__);
  return $form;
}