You are here

function wsconfig_edit_form_validate in Web Service Data 7

Form API validate callback for the wsconfig form

1 string reference to 'wsconfig_edit_form_validate'
wsconfig_edit_form in modules/wsconfig/wsconfig.admin.inc
Form callback: create or edit a wsconfig.

File

modules/wsconfig/wsconfig.admin.inc, line 229
Admin forms for wsconfig

Code

function wsconfig_edit_form_validate(&$form, &$form_state) {
  $wsconfig = $form_state['wsconfig'];

  // Notify field widgets to validate their data.
  field_attach_form_validate('wsconfig', $wsconfig, $form, $form_state);
  if ($form_state['triggering_element']['#id'] == 'edit-addmethod-submit') {
    $name = 'addmethod_name_' . $form_state['values']['addmethod'];
    if (isset($form[$name])) {
      $methodname = preg_replace('/\\W/', '', $form_state['values'][$name]);
      if (empty($methodname) or !preg_match('/[A-Za-z0-9]/', $methodname)) {
        form_error($form[$name], t('Method requires a name'));
      }
      elseif (isset($wsconfig->data[$wsconfig
        ->getMethodKey($form_state['values']['addmethod'] . '_' . $methodname)])) {
        form_error($form[$name], t('Method name already used'));
      }
    }
  }
}