You are here

function stringoverrides_textbox_combo in String Overrides 7

Same name and namespace in other branches
  1. 5 stringoverrides.admin.inc \stringoverrides_textbox_combo()
  2. 6 stringoverrides.admin.inc \stringoverrides_textbox_combo()

Function to return a textbox combo form.

1 call to stringoverrides_textbox_combo()
stringoverrides_admin in ./stringoverrides.admin.inc
Menu callback for the String Overrides module to display its administration

File

./stringoverrides.admin.inc, line 147
Admin page callbacks for the String Overrides module.

Code

function stringoverrides_textbox_combo($delta = 0, $enabled = TRUE, $context = '', $source = '', $translation = '') {
  $form['#tree'] = TRUE;
  $form['enabled'] = array(
    '#type' => 'checkbox',
    '#default_value' => $enabled == -1 ? TRUE : $enabled,
    // Have access if it's not a placeholder value.
    '#access' => $enabled != -1,
    '#attributes' => array(
      'title' => t('Flag whether this override should be active.'),
    ),
  );
  $form['source'] = array(
    '#type' => 'textarea',
    '#default_value' => $source,
    '#rows' => 1,
    '#attributes' => array(
      'title' => t('The original source text to be replaced.'),
    ),
  );
  $form['translation'] = array(
    '#type' => 'textarea',
    '#default_value' => $translation,
    '#rows' => 1,
    '#attributes' => array(
      'title' => t('The text to replace the original source text.'),
    ),
    // Hide the translation when the source is empty.
    '#states' => array(
      'invisible' => array(
        "#edit-string-{$delta}-source" => array(
          'empty' => TRUE,
        ),
      ),
    ),
  );
  $form['context'] = array(
    '#type' => 'textfield',
    '#default_value' => $context,
    '#size' => 5,
    '#maxlength' => 255,
    '#attributes' => array(
      'title' => t('Strings sometimes can have context applied to them. Most cases, this is not the case.'),
    ),
    // Hide the context when the source is empty.
    '#states' => array(
      'invisible' => array(
        "#edit-string-{$delta}-source" => array(
          'empty' => TRUE,
        ),
      ),
    ),
  );
  return $form;
}