You are here

function tablefield_field_widget_settings_form in TableField 7.3

Implements hook_field_widget_settings_form().

File

./tablefield.module, line 300
Provides a set of fields that can be used to store tabular data with a node.

Code

function tablefield_field_widget_settings_form($field, $instance) {
  $form = array();
  $form['restrict_rebuild'] = array(
    '#type' => 'checkbox',
    '#title' => t('Restrict rebuilding'),
    '#description' => t('Avoid the number of cols/rows being changed by content editors. For all users in combination with locked cells below. For users without the permission "rebuild tablefield" in other cases.') . '<br />' . t('Also needed if added or removed rows from the default field settings should apply on the edit form of existing content.'),
    '#default_value' => isset($instance['widget']['settings']['restrict_rebuild']) ? $instance['widget']['settings']['restrict_rebuild'] : FALSE,
  );
  $form['lock_values'] = array(
    '#type' => 'checkbox',
    '#title' => t('Lock cells with default values'),
    '#description' => t('Avoid headers being changed by content editors.'),
    '#default_value' => isset($instance['widget']['settings']['lock_values']) ? $instance['widget']['settings']['lock_values'] : FALSE,
  );
  $form['input_type'] = array(
    '#type' => 'radios',
    '#title' => t('Input type'),
    '#default_value' => isset($instance['widget']['settings']['input_type']) ? $instance['widget']['settings']['input_type'] : 'textfield',
    '#required' => TRUE,
    '#options' => array(
      'textfield' => t('textfield'),
      'textarea' => t('textarea'),
    ),
  );
  $form['max_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum cell length'),
    '#default_value' => isset($instance['widget']['settings']['max_length']) ? $instance['widget']['settings']['max_length'] : '2048',
    '#element_validate' => array(
      'tablefield_validate_number',
    ),
    '#size' => 6,
    '#maxlength' => 6,
    '#min' => 1,
    '#step' => 1,
    '#field_suffix' => t('characters'),
    '#attributes' => array(
      'class' => array(
        'tablefield-form-align',
      ),
    ),
    '#required' => TRUE,
  );
  $form['cell_processing'] = array(
    '#type' => 'radios',
    '#title' => t('Table cell processing'),
    '#default_value' => isset($instance['widget']['settings']['cell_processing']) ? $instance['widget']['settings']['cell_processing'] : 0,
    '#options' => array(
      t('Plain text'),
      t('Filtered text (user selects input format)'),
    ),
  );
  $form['data_sources'] = array(
    '#type' => 'checkboxes',
    '#title' => 'Additional data sources',
    '#description' => t('Note this setting gets overridden for users with the permission "always use additional datasources".'),
    '#options' => array(
      'paste' => t('Copy & Paste'),
      'upload' => t('Upload CSV file'),
    ),
    '#default_value' => isset($instance['widget']['settings']['data_sources']) ? $instance['widget']['settings']['data_sources'] : array(
      'paste',
      'upload',
    ),
  );
  return $form;
}