You are here

function boxes_validate_delta in Boxes 7

Same name and namespace in other branches
  1. 6 boxes.admin.inc \boxes_validate_delta()

Validate handler for box delta.

1 string reference to 'boxes_validate_delta'
boxes_add_form in ./boxes.admin.inc
Generate form for creating new boxes.

File

./boxes.admin.inc, line 26

Code

function boxes_validate_delta($element, &$form_state) {
  if (!preg_match('!^[a-z0-9_]+$!', $element['#value'])) {
    form_error($element, t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
  }
  if (strpos($element['#value'], 'boxes_add__') === 0 || boxes_box_load($element['#value'])) {
    form_error($element, t('The machine-readable name is already taken.'));
  }
}