You are here

function simplemeta_page_meta_form in Simple Meta 7

On-page SimpleMeta form builder.

2 string references to 'simplemeta_page_meta_form'
simplemeta_page_alter in ./simplemeta.module
Implements hook_page_alter().
simplemeta_page_meta_form_ajax_language in ./simplemeta.module
AJAX callback for language element of the simplemeta_page_meta_form.

File

./simplemeta.module, line 541
SimpleMeta module.

Code

function simplemeta_page_meta_form($form, &$form_state, $meta) {
  $form_id = 'simplemeta_meta_form';
  $_form_state = $form_state;
  $_form_state['build_info'] = array(
    'args' => array(
      $meta,
    ),
  );

  // Use simplemeta_meta_form as a base so alter hooks for simplemeta_meta_form will work here too.
  // @todo do not use simplemeta_meta_form as a base, but hook_form_alter() (and its more specific version) will need to alter both forms (in case changes need to appear on both).
  $form = drupal_retrieve_form($form_id, $_form_state);
  drupal_prepare_form($form_id, $form, $_form_state);
  if (variable_get('simplemeta_language_enable', FALSE)) {
    $form['_language']['#disabled'] = FALSE;
    unset($form['_language']['#value']);
    $form['_language']['#ajax'] = array(
      'wrapper' => 'simplemeta-meta-form-ajax-wrapper',
      'callback' => 'simplemeta_page_meta_form_ajax_language',
    );
  }
  $form['_buttons']['save']['#submit'][] = 'simplemeta_page_meta_form_submit_save';
  if (!empty($meta->sid)) {
    $form['_buttons']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#attributes' => array(
        'class' => array(
          'button-delete',
        ),
      ),
      '#submit' => array(
        'simplemeta_page_meta_form_submit_delete',
      ),
    );
  }
  $form['#prefix'] = '<div id="simplemeta-meta-form-ajax-wrapper">';
  $form['#suffix'] = '</div>';
  $form['#attributes']['class'] = array(
    'simplemeta-meta-form-ajax',
  );

  // Use the same id attribute for both admin and on-page forms.
  $form['#id'] = 'simplemeta-meta-form';
  return $form;
}