You are here

function wshybridfield_field_widget_form in Web Service Data 7

Implements hook_field_widget_form().

File

modules/wshybridfield/wshybridfield.module, line 47

Code

function wshybridfield_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $element['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => isset($items[$delta]['name']) ? $items[$delta]['name'] : '',
  );
  $operations = array();
  foreach (wsconfig_get_list_by_name() as $machinename => $name) {
    $wsconfig = wsconfig_load_by_name($machinename);
    foreach ($wsconfig
      ->getOperations() as $opname) {
      $operations["{$machinename}:{$opname}"] = $name . " - " . $wsconfig
        ->getMethodName($opname);
    }
  }
  $element['wsconfig_method'] = array(
    '#type' => 'select',
    '#title' => t('Web Service Config and Method'),
    '#description' => t('The web service and method to use'),
    '#options' => $operations,
    '#default_value' => isset($items[$delta]['wsconfig_method']) ? $items[$delta]['wsconfig_method'] : '',
  );
  $element['replacements'] = array(
    '#type' => 'textfield',
    '#title' => t('Replacements'),
    '#description' => t('JSON encoded replacements to pass to the wsconfig'),
    '#default_value' => isset($items[$delta]['replacements']) ? $items[$delta]['replacements'] : '',
  );
  $element['arguments'] = array(
    '#type' => 'textfield',
    '#title' => t('Arguments'),
    '#description' => t('JSON encoded arguments to pass to the wsconfig'),
    '#default_value' => isset($items[$delta]['arguments']) ? $items[$delta]['arguments'] : '',
  );
  $element['options'] = array(
    '#type' => 'textfield',
    '#title' => t('Options'),
    '#description' => t('JSON encoded options'),
    '#default_value' => isset($items[$delta]['options']) ? $items[$delta]['options'] : '',
  );
  return $element;
}