You are here

function table_trash_validate_machine_names in Table Trash 7

Validation function for table_trash_admin_update_config_form to make sure all machine names are unique.

1 string reference to 'table_trash_validate_machine_names'
table_trash_admin_update_config_form in ./table_trash.admin.inc
Menu callback for the update path.

File

./table_trash.admin.inc, line 214
table_trash.admin.inc

Code

function table_trash_validate_machine_names($form, &$form_state) {
  $machine_names = array();
  foreach ($form_state['values']['decorations'] as $key => $decoration) {
    $machine_names[$key] = $decoration['machine_name'];
  }
  $dups = array_count_values($machine_names);
  foreach ($machine_names as $key => $name) {
    if ($dups[$name] > 1) {
      form_set_error("decorations][{$key}][machine_name", "Machine names must be unique.");
    }
  }
}