You are here

function picture_background_formatter_field_formatter_settings_form in Picture Background Formatter 7

Implements hook_field_formatter_settings_form().

File

./picture_background_formatter.module, line 30
Hooks and functions for the Picture Background Formatter module.

Code

function picture_background_formatter_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $options = picture_get_mapping_options();
  if ($options) {
    $element['picture_mapping'] = array(
      '#title' => t('Picture mapping'),
      '#type' => 'select',
      '#default_value' => isset($settings['picture_mapping']) ? $settings['picture_mapping'] : '',
      '#required' => TRUE,
      '#options' => picture_get_mapping_options(),
    );
    $element['selector'] = array(
      '#type' => 'textfield',
      '#title' => t('Selector'),
      '#description' => t('CSS Selector for background image.'),
      '#default_value' => $settings['selector'],
    );
  }
  else {
    $element['picture_mapping'] = array(
      '#title' => t('Picture mapping'),
      '#type' => 'item',
      '#markup' => t('There are no picture groups defined. !create_link.', array(
        '!create_link' => l(t('Create a picture mapping'), 'admin/config/media/picture/add'),
      )),
    );
  }
  return $element;
}