You are here

function views_bulk_operations_views_bulk_operations_fields in Views Bulk Operations (VBO) 6

Implementation of hook_views_bulk_operations_fields(). Return field definitions for common Drupal node fields: array( field_name => array( 'label' => label to display in admin settings 'form' => array of form elements 'validate' => array of functions to handle validation of submitted values for the form elements 'submit' => array of functions to handle further node changes after values have been copied over ), )

File

actions/fields.action.inc, line 415
Drupal action to set individual field values.

Code

function views_bulk_operations_views_bulk_operations_fields($type) {
  $fields = array();
  $fields['title'] = array(
    'label' => t('Title'),
    'form' => array(
      'title' => array(
        '#type' => 'textfield',
        '#title' => t('Title'),
      ),
    ),
  );
  $fields['body_field'] = array(
    'label' => t('Body'),
    'form' => array(
      'body_field' => array(
        '#tree' => TRUE,
        'body' => array(
          '#type' => 'textarea',
          '#title' => t('Body'),
        ),
        'format' => filter_form(FILTER_FORMAT_DEFAULT, NULL, array(
          'body_field',
          'format',
        )),
      ),
    ),
  );
  $fields['publishing'] = array(
    'label' => t('Publishing options'),
    'form' => array(
      'publishing' => array(
        '#tree' => TRUE,
        'publishing_options' => array(
          '#value' => t('Publishing options') . ':',
          '#prefix' => '<div class="form-item"><label>',
          '#suffix' => '</label></div>',
          '#ignore' => TRUE,
        ),
        'status' => array(
          '#type' => 'checkbox',
          '#title' => t('Published'),
        ),
        'promote' => array(
          '#type' => 'checkbox',
          '#title' => t('Promoted to front page'),
        ),
        'sticky' => array(
          '#type' => 'checkbox',
          '#title' => t('Sticky at top of lists'),
        ),
      ),
    ),
  );
  $fields['authoring'] = array(
    'label' => t('Authoring information'),
    'form' => array(
      'authoring' => array(
        '#tree' => TRUE,
        'name' => array(
          '#type' => 'textfield',
          '#title' => t('Authored by'),
          '#maxlength' => 60,
          '#autocomplete_path' => 'user/autocomplete',
          '#weight' => -1,
          '#description' => t('Leave blank for %anonymous.', array(
            '%anonymous' => variable_get('anonymous', t('Anonymous')),
          )),
        ),
        'date' => array(
          '#type' => 'textfield',
          '#title' => t('Authored on'),
          '#maxlength' => 25,
          '#description' => t('Format: %time. Leave blank to use the time of form submission.', array(
            '%time' => '2011-01-25 12:00:00 +0200',
          )),
        ),
      ),
    ),
    'validate' => array(
      '_views_bulk_operations_field_action_validate_authoring',
    ),
    'submit' => array(
      '_views_bulk_operations_field_action_submit_authoring',
    ),
  );
  if (module_exists('comment')) {
    $fields['comment'] = array(
      'label' => t('Comment settings'),
      'form' => array(
        'comment' => array(
          '#title' => t('Comment settings'),
          '#type' => 'radios',
          '#parents' => array(
            'comment',
          ),
          '#options' => array(
            t('Disabled'),
            t('Read only'),
            t('Read/Write'),
          ),
        ),
      ),
    );
  }
  if (module_exists('locale')) {
    $fields['language'] = array(
      'label' => t('Language'),
      'form' => array(
        'language' => array(
          '#type' => 'select',
          '#title' => t('Language'),
          '#options' => array(
            '' => t('Language neutral'),
          ) + locale_language_list('name'),
        ),
      ),
    );
  }
  return $fields;
}