You are here

function add_to_head_edit_profile in Add To Head 6

Same name and namespace in other branches
  1. 7 add_to_head.admin.inc \add_to_head_edit_profile()

This function provides the edit form. The Add Profile form also uses this.

See also

add_to_head_forms()

2 string references to 'add_to_head_edit_profile'
add_to_head_forms in ./add_to_head.module
Implementation of hook_forms().
add_to_head_menu in ./add_to_head.module
Implementation of hook_menu().

File

./add_to_head.admin.inc, line 51
This file contains all the admin-related callbacks

Code

function add_to_head_edit_profile(&$form_state, $profile = NULL) {
  $form = array();
  $form['name_orig'] = array(
    '#type' => 'value',
    '#value' => isset($profile['name']) ? $profile['name'] : '',
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#description' => t('This is the unique name for this profile'),
    '#required' => TRUE,
    '#default_value' => isset($profile['name']) ? $profile['name'] : '',
  );
  $form['code'] = array(
    '#type' => 'textarea',
    '#title' => t('Code'),
    '#description' => t('Enter the code you would like to insert into the head of the page'),
    '#required' => TRUE,
    '#default_value' => isset($profile['code']) ? $profile['code'] : '',
    '#wysiwyg' => FALSE,
  );
  $form['path_visibility'] = array(
    '#type' => 'radios',
    '#title' => t('Embed code on specific pages'),
    '#options' => array(
      0 => t('Show on every page except the listed pages.'),
      1 => t('Show on only the listed pages.'),
    ),
    '#default_value' => isset($profile['path_visibility']) ? $profile['path_visibility'] : '',
  );
  $form['paths'] = array(
    '#type' => 'textarea',
    '#title' => t('Paths'),
    '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    )),
    '#required' => TRUE,
    '#default_value' => isset($profile['paths']) ? $profile['paths'] : '',
    '#wysiwyg' => FALSE,
  );
  $form['scope'] = array(
    '#type' => 'radios',
    '#title' => t('Scope of addition'),
    '#description' => t('Which section of the head would you like this snippet appended to?'),
    '#options' => array(
      'head' => t('Head - This appears early on in the head (before any CSS and JS are included)'),
      'styles' => t('Styles - It will be appended to the CSS files section. This is usually before any other JS is included.'),
      'scripts' => t('Scripts - It will be appended to the Javascripts section. This can, sometimes, be in the footer of the document depending on the theme.'),
    ),
    '#default_value' => isset($profile['scope']) ? $profile['scope'] : '',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['#submit'][] = 'add_to_head_edit_profile_validate';
  $form['#submit'][] = 'add_to_head_edit_profile_submit';
  return $form;
}