You are here

function devel_variable_edit in Devel 7

Same name and namespace in other branches
  1. 5 devel.module \devel_variable_edit()
  2. 6 devel.module \devel_variable_edit()

Form constructor for editing a variable.

See also

devel_variable_edit_submit()

1 string reference to 'devel_variable_edit'
devel_menu in ./devel.module
Implements hook_menu().

File

./devel.pages.inc, line 311
Page callbacks for Devel.

Code

function devel_variable_edit($form, &$form_state, $name) {
  $value = variable_get($name, 'not found');
  $form['name'] = array(
    '#type' => 'value',
    '#value' => $name,
  );
  $form['value'] = array(
    '#type' => 'item',
    '#title' => t('Old value'),
    '#markup' => dpr($value, TRUE),
  );
  if (is_string($value) || is_numeric($value)) {
    $form['new'] = array(
      '#type' => 'textarea',
      '#title' => t('New value'),
      '#default_value' => $value,
    );
    $form['actions'] = array(
      '#type' => 'actions',
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );
  }
  else {
    $api = variable_get('devel_api_url', 'api.drupal.org');
    $form['new'] = array(
      '#type' => 'item',
      '#title' => t('New value'),
      '#markup' => t('Sorry, complex variable types may not be edited yet. Use the <em>Execute PHP</em> block and the <a href="@variable-set-doc">variable_set()</a> function.', array(
        '@variable-set-doc' => "http://{$api}/api/HEAD/function/variable_set",
      )),
    );
  }
  drupal_set_title($name);
  return $form;
}