You are here

function rules_link_form_validate in Rules Link 7

Same name and namespace in other branches
  1. 7.2 rules_link.admin.inc \rules_link_form_validate()

Validation form for editing form.

File

./rules_link.admin.inc, line 364
Generate a admin UI.

Code

function rules_link_form_validate(&$form, &$form_state) {
  $rules_link = entity_ui_form_submit_build_entity($form, $form_state);
  if (!entity_property_verify_data_type($rules_link->name, 'token')) {
    form_error($form['name'], t('The name "%name" is not a valid name. Please select a different name.', array(
      '%name' => $rules_link->name,
    )));
  }
  $path = empty($rules_link->path) ? $rules_link->name : $rules_link->path;
  $menu_item = menu_get_item($path);
  $lookup_path = drupal_lookup_path('source', $path);
  if (!empty($menu_item) || !empty($lookup_path)) {
    form_error($form['path'], t('The path "%path" is already in use. This system cannot override existing paths. Please select a different name or enter a different path.', array(
      '%path' => $path,
    )));
  }
  foreach (rules_link_get_links() as $link) {
    if ($link->path == $path && $link->name != $rules_link->name) {
      form_error($form['path'], t('The path "%path" is taken by the rules link "%link". This system cannot override existing paths.', array(
        '%path' => $path,
        '%link' => $link->name,
      )));
    }
  }
}