So, I'm trying to implement a Salesforce generated Web-to-Case form on my Drupal site. I have implemented the form correctly so that it updates the Salesforce application cases, but for some reason the form doesn't get validated before submission. I have placed the form in a block with a custom module for portability and versatility. Here is the code for the form. Neither the required fields, nor my attempt to validate the form are enforced before submission. I'm pasting my code below stripped of extraneous fields to for demonstration.
function web_to_case_form($form, &$form_state){
$form = array(
'#action' => 'https://webto.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8',
);
$form['lastname'] = array(
'#id' => '00N6A000009vWYv',
'#name' => '00N6A000009vWYv',
'#required' => TRUE,
'#title' => t('Last Name'),
'#type' => 'textfield',
'#maxlength' => 30,
'#size' => 20,
);
$form['maidenname'] = array(
'#id' => '00N6A000009vWYM',
'#name' => '00N6A000009vWYM',
'#title' => t('Maiden Name'),
'#required' => TRUE,
'#type' => 'textfield',
'#maxlength' => 30,
'#size' => 20,
);
$form['email'] = array(
'#id' => 'email',
'#title' => t('Email'),
'#name' => 'email',
'#required' => TRUE,
'#type' => 'textfield',
'#maxlength' => 80,
'#size' => 20,
);
$form['phone'] = array(
'#id' => 'phone',
'#title' => t('Phone'),
'#name' => 'phone',
'#required' => TRUE,
'#type' => 'textfield',
'#maxlength' => 80,
'#size' => 20,
'#element_validate' => array('element_validate_number '),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
function web_to_case_form_validate($form, &$form_state) {
$email = $form_state['values']['email'];
// Verify that the email address is valid.
if (!valid_email_address($email)) {
form_set_error('email', t('You must provide a valid email address.'));
}
}
Is this because the form is being submitted to an external URL? If that's the case, how to I validate a form before submission? Otherwise, not sure what's going on here. I've even tried to add a validate element to one of the form elements, but that doesn't seem to work either.