function ds_build_mode_form_validate in Display Suite 6
Same name and namespace in other branches
- 6.3 includes/ds.buildmodes.inc \ds_build_mode_form_validate()
- 6.2 includes/ds.buildmodes.inc \ds_build_mode_form_validate()
Validate new custom build mode submission.
File
- includes/
ds.buildmodes.inc, line 123 - Manage build modes.
Code
function ds_build_mode_form_validate($form, &$form_state) {
if ($form['#form_type'] == 'insert') {
$existing = array_keys(ds_get_build_modes($form['#module']));
if (in_array($form_state['values']['key'], $existing)) {
form_set_error('key', t('This build mode already exists.'));
}
if (!preg_match('!^[a-z_0-9]+$!', $form_state['values']['key'])) {
form_set_error('key', t('The machine-readable name must contain only lowercase letters, numbers and underscores.'));
}
}
}