function webform_component_edit_form_validate in Webform 6.3
Same name and namespace in other branches
- 5.2 webform_components.inc \webform_component_edit_form_validate()
- 6.2 webform_components.inc \webform_component_edit_form_validate()
- 7.4 includes/webform.components.inc \webform_component_edit_form_validate()
- 7.3 includes/webform.components.inc \webform_component_edit_form_validate()
Field name validation for the webform unique key. Must be alphanumeric.
File
- includes/
webform.components.inc, line 614 - Webform module component handling.
Code
function webform_component_edit_form_validate($form, &$form_state) {
$node = node_load($form_state['values']['nid']);
if (!preg_match('/^[a-z0-9_]+$/i', $form_state['values']['form_key'])) {
form_set_error('form_key', t('The field key %field_key is invalid. Please include only lowercase alphanumeric characters and underscores.', array(
'%field_key' => $form_state['values']['form_key'],
)));
}
foreach ($node->webform['components'] as $cid => $component) {
if (($component['cid'] != $form_state['values']['cid'] || $form_state['values']['clone']) && $component['pid'] == $form_state['values']['pid'] && strcasecmp($component['form_key'], $form_state['values']['form_key']) == 0) {
form_set_error('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_state['values']['form_key'],
'%existing_field' => $component['name'],
)));
}
}
}