You are here

function shorten_cs_add_form in Shorten URLs 6

Same name and namespace in other branches
  1. 7.2 shorten_cs.admin.inc \shorten_cs_add_form()
  2. 7 shorten_cs.admin.inc \shorten_cs_add_form()

Builds the form to add a new custom service.

1 call to shorten_cs_add_form()
shorten_cs_edit in ./shorten_cs.admin.inc
Builds the form to edit a custom service.
1 string reference to 'shorten_cs_add_form'
theme_shorten_cs_admin in ./shorten_cs.admin.inc
Themes the configuration page.

File

./shorten_cs.admin.inc, line 44
Provides the configuration page for Shorten URLs Custom Services.

Code

function shorten_cs_add_form($form_state) {
  drupal_add_js(drupal_get_path('module', 'shorten_cs') . '/shorten_cs.js');
  $form = array(
    '#attributes' => array(
      'class' => 'shorten-cs-apply-js',
    ),
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#description' => t('The name of the service'),
    '#required' => TRUE,
  );
  $form['url'] = array(
    '#type' => 'textfield',
    '#title' => t('API endpoint URL'),
    '#description' => t('The URL of the API endpoint, with parameters, such that the long URL can be appended to the end.') . ' ' . t('For example, the endpoint for TinyURL is') . ' <code>http://tinyurl.com/api-create.php?url=</code>.' . t('Appending a long URL to the endpoint and then visiting that address will return data about the shortened URL.'),
    '#required' => TRUE,
  );
  $form['type'] = array(
    '#type' => 'radios',
    '#title' => t('Response type'),
    '#description' => t('The type of response the API endpoint returns.'),
    '#required' => TRUE,
    '#default_value' => 'text',
    '#options' => array(
      'text' => t('Text'),
      'xml' => 'XML',
      'json' => 'JSON',
    ),
  );
  $form['tag'] = array(
    '#type' => 'textfield',
    '#title' => t('XML tag or JSON key'),
    '#description' => t('The XML tag or JSON key that identifies the full short URL in the API response.') . ' ' . t('Only required for XML and JSON response types.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}