You are here

function imagefield_tokens_form_alter in ImageField Tokens 6

Same name and namespace in other branches
  1. 5 imagefield_tokens.module \imagefield_tokens_form_alter()

Implementation of hook_form_alter().

File

./imagefield_tokens.module, line 21

Code

function imagefield_tokens_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['widget_module']) && in_array($form['widget_module']['#value'], _imagefield_tokens_support_list())) {
    $ifp = array(
      'alt' => array(
        'title' => 'ALT text',
        'form_path' => &$form['widget']['alt_settings'],
      ),
      'title' => array(
        'title' => 'Title text',
        'form_path' => &$form['widget']['title_settings'],
      ),
    );
    foreach ($ifp as $name => &$field) {
      unset($field['form_path'][$name]['#suffix']);
      $field['form_path'][$name . '_tokens'] = array(
        '#type' => 'fieldset',
        '#title' => t('!title replacement patterns', array(
          '!title' => $field['title'],
        )),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#description' => theme_filefield_paths_token_help(),
      );
    }
  }
}