function menu_token_form_menu_edit_item_validate in Menu Token 7
Same name and namespace in other branches
- 6 menu_token.admin.inc \menu_token_form_menu_edit_item_validate()
Custom validation for form menu_edit_item.
1 string reference to 'menu_token_form_menu_edit_item_validate'
- menu_token_form_menu_edit_item_alter in ./
menu_token.module - Implementation of hook_form_FORM_ID_alter().
File
- ./
menu_token.module, line 513 - Main module file for the Menu Token module.
Code
function menu_token_form_menu_edit_item_validate($form, &$form_state) {
$values =& $form_state['values'];
// If token replacing is enabled and this is a custom menu item.
if (in_array($values['module'], array(
'menu',
'system',
)) && !empty($values['menu_token_enabled'])) {
// Substitute link_path with our own unique menu path. This will make sure features will export our menu items.
$values['options']['menu_token_link_path'] = $values['link_path'];
// Set 'alter' option to use hook_translated_menu_link_alter()
$values['options']['alter'] = TRUE;
// If a uuid already exists, don't change it
$uuid_path = !empty($values['menu_token_uuid']) ? $values['menu_token_uuid'] : 'menutoken/' . uniqid();
$values['link_path'] = $uuid_path;
$values['options']['menu_token_link_uuid'] = $uuid_path;
foreach (array_keys(menu_token_get_plugin_types()) as $type) {
if (!empty($values['menu_token_type_' . $type]) && $values['menu_token_type_' . $type] != '_none') {
$plugin = $values['menu_token_type_' . $type];
if ($handler = menu_token_get_handler($plugin)) {
// Validate the form via the handler.
$form_state['_menu_token_entity_type'] = $type;
$handler
->form_validate($form, $form_state);
}
}
}
}
}