You are here

function imagecache_ui_preset_form_validate in ImageCache 6.2

File

./imagecache_ui.pages.inc, line 271

Code

function imagecache_ui_preset_form_validate($form, &$form_state) {
  $values = $form_state['values'];

  // Check for duplicates
  foreach (imagecache_presets() as $preset) {
    if ($values['presetname'] == $preset['presetname'] && $values['presetid'] != $preset['presetid']) {
      form_set_error('presetname', t('The preset name you have chosen is already in use.'));
      break;
    }
  }

  // Check for illegal characters in preset names
  if (preg_match('/[^0-9a-zA-Z_\\-]/', $values['presetname'])) {
    form_set_error('presetname', t('Please only use alphanumeric characters, underscores (_), and hyphens (-) for preset names.'));
  }
}