You are here

function iframe_field_settings_form in Iframe 7

Implements hook_field_settings_form(). These settings apply to the iframe field everywhere(!) it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created. Field XYZ sub-menu "Field settings" (Step 2)

File

./iframe.module, line 107
Defines an iframe field with all attributes.

Code

function iframe_field_settings_form($field, $instance, $has_data) {
  $settings = $field['settings'];

  // as defined in iframe_field_info()
  $form = array();
  if ($field['type'] == 'iframe') {
    $form['class'] = array(
      '#type' => 'textfield',
      '#title' => t('Additional CSS Class'),
      '#default_value' => !empty($settings['class']) ? $settings['class'] : '',
      '#description' => t('When output, this iframe will have this class attribute. Multiple classes should be separated by spaces.'),
    );
    $form['frameborder'] = array(
      '#type' => 'select',
      '#title' => t('Frameborder'),
      '#options' => array(
        '0' => t('No frameborder'),
        '1' => t('Show frameborder'),
      ),
      '#default_value' => !empty($settings['frameborder']) ? $settings['frameborder'] : 0,
      '#description' => t('Frameborder is the border arround the iframe. Mostly people want it silent, so the default value for frameborder is 0 = no.'),
    );
    $form['scrolling'] = array(
      '#type' => 'select',
      '#title' => t('Scrolling'),
      '#options' => array(
        'auto' => t('Scrolling automatic'),
        'no' => t('Scrolling disabled'),
        'yes' => t('Scrolling enabled'),
      ),
      '#default_value' => !empty($settings['scrolling']) ? $settings['scrolling'] : 'auto',
      '#description' => t('Scrollbars help the user to reach all iframe content despite the real height of the iframe content. Please disable it only if You know what You are doing.'),
    );
    $form['transparency'] = array(
      '#type' => 'select',
      '#title' => t('Transparency'),
      '#options' => array(
        '0' => t('No transparency'),
        '1' => t('Allow transparency'),
      ),
      '#default_value' => !empty($settings['transparency']) ? $settings['transparency'] : '0',
      '#description' => t('Allow transparency per CSS in the outer iframe tag. You have to set background-color:transparent in your iframe body tag too!'),
    );
    $form['tokensupport'] = array(
      '#type' => 'select',
      '#title' => t('Token Support'),
      '#options' => array(
        '0' => t('No tokens allowed'),
        '1' => t('Tokens only in title field'),
        '2' => t('Tokens for title and url field'),
      ),
      '#default_value' => !empty($settings['tokensupport']) ? $settings['tokensupport'] : '0',
      '#description' => t('Are tokens allowed for users to use in title or URL field?'),
    );
    if (!module_exists('token')) {
      $form['tokensupport']['#description'] .= ' ' . t('Attention: token module is not enabled currently!');
    }
  }
  return $form;
}