You are here

function nd_block_field_form_validate in Node displays 6

Validate block field submission, only on insert.

File

includes/nd.fields.inc, line 299
Manage fields.

Code

function nd_block_field_form_validate($form, &$form_state) {
  if ($form['#form_type'] == 'insert') {
    $fields = variable_get('nd_fields', array());
    $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_]+$!', $form_state['values']['block_key'])) {
      form_set_error('block_key', t('The machine-readable name must contain only lowercase letters and underscores.'));
    }
  }
}