You are here

function ds_edit_custom_field_form in Display Suite 7.2

Same name and namespace in other branches
  1. 7 ds.fields.inc \ds_edit_custom_field_form()

Manage a custom field.

2 string references to 'ds_edit_custom_field_form'
ds_ajax_add_field in modules/ds_ui/includes/ds.fields.inc
Handles ctools modal Add field
ds_ui_menu in modules/ds_ui/ds_ui.module
Implements hook_menu().

File

modules/ds_ui/includes/ds.fields.inc, line 315
Administrative functions for managing custom fields for every entity.

Code

function ds_edit_custom_field_form($form, &$form_state, $custom_field = '') {
  drupal_set_title(empty($custom_field) ? t('Add a code field') : t('Edit code field'));
  $custom_field = ds_shared_form($form, $custom_field);
  $form['code'] = array(
    '#type' => 'text_format',
    '#title' => t('Field code'),
    '#default_value' => isset($custom_field->properties['code']['value']) ? $custom_field->properties['code']['value'] : '',
    '#format' => isset($custom_field->properties['code']['format']) ? $custom_field->properties['code']['format'] : 'ds_code',
    '#base_type' => 'textarea',
    '#required' => TRUE,
  );
  $form['use_token'] = array(
    '#type' => 'checkbox',
    '#title' => t('Token'),
    '#description' => t('Toggle this checkbox if you are using tokens in this field.'),
    '#default_value' => isset($custom_field->properties['use_token']) ? $custom_field->properties['use_token'] : '',
  );

  // Token support.
  if (module_exists('token')) {
    $form['tokens'] = array(
      '#title' => t('Tokens'),
      '#type' => 'container',
      '#states' => array(
        'invisible' => array(
          'input[name="use_token"]' => array(
            'checked' => FALSE,
          ),
        ),
      ),
    );
    $form['tokens']['help'] = array(
      '#theme' => 'token_tree',
      '#token_types' => 'all',
      '#global_types' => FALSE,
      '#dialog' => TRUE,
    );
  }
  else {
    $form['use_token']['#description'] = t('Toggle this checkbox if you are using tokens in this field. If the token module is installed, you get a nice list of all tokens available in your site.');
  }
  $form['#validate'][] = 'ds_custom_field_form_validate';
  return $form;
}