function ds_block_field_form_validate in Display Suite 6.3
Same name and namespace in other branches
- 6 includes/ds.fields.inc \ds_block_field_form_validate()
- 6.2 includes/ds.fields.inc \ds_block_field_form_validate()
- 7.2 modules/ds_ui/includes/ds.fields.inc \ds_block_field_form_validate()
- 7 ds.fields.inc \ds_block_field_form_validate()
Validate block field submission, only on insert.
File
- includes/
ds.fields.inc, line 634 - Manage fields.
Code
function ds_block_field_form_validate($form, &$form_state) {
if ($form['#form_type'] == 'insert') {
$module = $form['#module'];
$fields = $form['#all_fields'];
$existing = array_keys($fields);
if (in_array($form_state['values']['block_key'], $existing)) {
form_set_error('block_key', t('This field already exists.'));
}
if (!preg_match('!^[a-z_0-9]+$!', $form_state['values']['block_key'])) {
form_set_error('block_key', t('The machine-readable name must contain only lowercase letters, numbers and underscores.'));
}
}
}