You are here

function taxonomy_revision_field_attach_form in Taxonomy revision 7

Implements hook_field_attach_form().

File

./taxonomy_revision.module, line 239
This is the main module file for the Taxonomy revision module.

Code

function taxonomy_revision_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
  if ($entity_type == 'taxonomy_term' && !empty($entity->tid)) {
    $form['revision_information'] = array(
      '#type' => 'fieldset',
      '#title' => t('Revision information'),
      '#collapsible' => TRUE,
      '#weight' => 20,
      '#access' => user_access('choose taxonomy term revisions'),
    );
    if (!_taxonomy_revision_enabled_by_default($entity->vid)) {
      $form['revision_information']['revision'] = array(
        '#type' => 'checkbox',
        '#title' => t('Create new revision'),
      );
    }
    else {
      $form['revision_information']['revision'] = array(
        '#type' => 'markup',
        '#markup' => t('New revision will be created automatically.'),
      );
    }
    $form['revision_information']['log'] = array(
      '#type' => 'textarea',
      '#title' => t('Revision log message'),
      '#rows' => 4,
      '#description' => t('Provide an explanation of the changes you are making. This will help other authors understand your motivations.'),
    );
    if (!_taxonomy_revision_enabled_by_default($entity->vid)) {
      $form['revision_information']['log']['#states'] = array(
        'invisible' => array(
          'input[name="revision"]' => array(
            'checked' => FALSE,
          ),
        ),
      );
    }
    $form['#entity_builders'][] = 'taxonomy_revision_taxonomy_form_term_submit_build_term';
  }
}