You are here

function twilio_twiml_manager_form in Twilio 7

TwiML Manager form.

1 string reference to 'twilio_twiml_manager_form'
twilio_twiml_menu in twilio_twiml/twilio_twiml.module
Implements hook_menu().

File

twilio_twiml/twilio_twiml.admin.inc, line 10
Administrative forms section

Code

function twilio_twiml_manager_form($form, &$form_state, $twiml_id = NULL) {

  // Load the TwiML data if it exists.
  $twiml = twilio_twiml_load($twiml_id);
  $twiml_list = twilio_twiml_load_multiple();
  $form = array();
  if (!empty($twiml_list)) {
    $form['list'] = array(
      '#theme' => 'twilio_twiml_list',
      '#twiml_list' => $twiml_list,
    );
  }
  $form['name'] = array(
    '#title' => t('Name'),
    '#type' => 'textfield',
    '#default_value' => $twiml['name'],
    '#description' => t('The human-readable name of this TwiML.'),
    '#required' => TRUE,
    '#size' => 30,
  );
  $form['twiml_id'] = array(
    '#type' => 'machine_name',
    '#default_value' => $twiml['twiml_id'],
    '#maxlength' => 32,
    '#disabled' => $twiml,
    '#machine_name' => array(
      'exists' => 'twilio_twiml_load',
    ),
    '#description' => t('A unique machine-readable name for this TwiML. It must only contain lowercase letters, numbers, and underscores.'),
  );
  $form['description'] = array(
    '#title' => t('Description'),
    '#type' => 'textfield',
    '#default_value' => $twiml['description'],
    '#description' => t('The description of this TwiML.'),
  );

  // If the PHP module is enabled show a different description.
  if (module_exists('php')) {
    $description = t('The TwiML. You may use PHP code. You should include <?php ?> tags.');
  }
  else {
    $description = t('The TwiML. If you wish to use PHP code you must enable the !phpmodule', array(
      '!phpmodule' => l(t('PHP filter module'), 'admin/modules'),
    ));
  }
  $form['data'] = array(
    '#title' => t('TwiML'),
    '#type' => 'textarea',
    '#default_value' => $twiml['data'],
    '#description' => $description,
  );
  $form['save'] = array(
    '#value' => $twiml ? t('Update TwiML') : t('Create TwiML'),
    '#type' => 'submit',
    '#name' => $twiml ? 'update' : 'save',
  );
  return $form;
}