function wsconfig_view_form in Web Service Data 7
Form callback: to view a wsconfig.
Parameters
$wsconfig: The wsconfig to use to view
1 string reference to 'wsconfig_view_form'
- wsconfig_view_form_wrapper in modules/
wsconfig/ wsconfig.admin.inc - Form callback wrapper: view a wsconfig.
File
- modules/
wsconfig/ wsconfig.admin.inc, line 323 - Admin forms for wsconfig
Code
function wsconfig_view_form($form, &$form_state, $wsconfig) {
$form_state['wsconfig'] = $wsconfig;
$ws_endpoint = wsconfig_get_types($wsconfig->type);
//ws endpoint display
$form['endpoint'] = array(
'#type' => 'item',
'#title' => t('Endpoint'),
'#markup' => $wsconfig->type . ' (' . $ws_endpoint->data['endpoint'] . ')',
);
foreach ($wsconfig
->getOperations() as $op) {
$method = $wsconfig
->getMethod($op);
if (!empty($method)) {
$form[$op] = array(
'#type' => 'fieldset',
'#title' => $wsconfig
->getMethodName($op),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form[$op]['method'] = array(
'#type' => 'item',
'#title' => $wsconfig
->getMethodName($op),
'#markup' => $method,
);
$matches = array();
preg_match_all("/(%\\w+)/", $method, $matches);
foreach ($matches[0] as $var) {
$form[$op][$op . ':' . $var] = array(
'#type' => 'textfield',
'#title' => $var,
'#default_value' => isset($form_state['values'][$var]) ? $form_state['values'][$var] : '',
);
}
$form[$op]['arguments'] = array(
'#type' => 'textfield',
'#title' => t('Arguments'),
'#description' => t('Arguments as a JSON array'),
'#default_value' => isset($form_state['values']['arguments']) ? $form_state['values']['arguments'] : '',
'#element_validate' => array(
'_wsconfig_element_validate_json',
),
'#maxlength' => 512,
);
$form[$op]['options'] = array(
'#type' => 'textfield',
'#title' => t('Options'),
'#description' => t('Options as a JSON array (Example: {"headers":{"Content-Type":"application/json"}} )'),
'#default_value' => isset($form_state['values']['options']) ? $form_state['values']['options'] : isset($wsconfig->data['options'][$op]) ? drupal_json_encode($wsconfig->data['options'][$op]) : '',
'#element_validate' => array(
'_wsconfig_element_validate_json',
),
'#maxlength' => 512,
);
$form[$op]['submit'] = array(
'#type' => 'submit',
'#name' => $op,
'#value' => $wsconfig
->getMethodName($op),
);
}
}
return $form;
}