function webform_edit_field_form_prepare_validate in Webform 5
Field name validation for the webform unique key. Must be alphanumeric.
1 call to webform_edit_field_form_prepare_validate()
- webform_prepare in ./
webform.module - Implementation of hook_prepare(). This function is called before the display of webform_form(). Rather than a typical usage of hook_prepare, in webform it is used to update the contents of the $node object after changes have been made to the node,…
File
- ./
webform.module, line 1102
Code
function webform_edit_field_form_prepare_validate($form_values, $node) {
if (!preg_match('!^[a-z0-9_]+$!', $form_values['form_key'])) {
form_set_error('field][form_key', t('The field key %field_key is invalid. Please include only lowercase alphanumeric characters and underscores.', array(
'%field_key' => $form_values['form_key'],
)));
}
foreach ($node->webformcomponents as $cid => $component) {
if ($component['cid'] != $form_values['cid'] && strcasecmp($component['form_key'], $form_values['form_key']) == 0 && $component['parent'] == $form_values['parent']) {
form_set_error('field][form_key', t('The field key %field_key is already in use by the field labeled %existing_field. Please use a unique key.', array(
'%field_key' => $form_values['form_key'],
'%existing_field' => $component['name'],
)));
}
}
// Let the field do any additional validation.
_webform_load_components($form_values['type']);
$validate_function = '_webform_edit_validate_' . $form_values['type'];
if (function_exists($validate_function)) {
$validate_function($form_values);
}
}