function pardot_webform_components_form_validate in Pardot Integration 7.2
Same name and namespace in other branches
- 7 pardot.admin.inc \pardot_webform_components_form_validate()
Form validation handler for pardot_webform_components_form().
See also
pardot_webform_components_form_submit()
File
- pardot_webform/
pardot_webform.admin.inc, line 118 - Webform admin file.
Code
function pardot_webform_components_form_validate($form, $form_state) {
// Check if we should validate the form handler.
if (variable_get('pardot_validate_url', 1)) {
// Just check if the URL is active. No validation done if it is not.
if ($form_state['values']['details']['is_active'] == 1) {
// If so, check if it's a valid url.
$check_url = $form_state['values']['details']['url'];
// Send data.
$result = drupal_http_request($check_url, array(
'timeout' => 5,
));
if ($result->code != 200) {
form_set_error('url', t('This is not a valid Pardot Post url.'));
}
else {
// Check to see if the Pardot cookie exists.
if (!strstr($result->headers['set-cookie'], 'pardot')) {
form_set_error('url', t('No cookie set, this is not a Pardot Post url.'));
}
else {
drupal_set_message(t('Valid Pardot Post url.'));
}
}
}
else {
// Print out message.
drupal_set_message(t('No validation done for none active Post URL'), 'status');
}
}
}