function path_breadcrumbs_ui_add_form_submit in Path Breadcrumbs 7.2
Same name and namespace in other branches
- 7.3 path_breadcrumbs_ui/path_breadcrumbs_ui.module \path_breadcrumbs_ui_add_form_submit()
Submit callback for path_breadcrumbs_ui_add_form.
_state
Parameters
$form:
1 string reference to 'path_breadcrumbs_ui_add_form_submit'
- path_breadcrumbs_ui_add_form in path_breadcrumbs_ui/
path_breadcrumbs_ui.module - Provides multistep form for create/edit path breadcrumbs.
File
- path_breadcrumbs_ui/
path_breadcrumbs_ui.module, line 249 - Provide user interface for CRUD operations with path breadcrumbs.
Code
function path_breadcrumbs_ui_add_form_submit($form, &$form_state) {
$values = $form_state['values'];
if (!empty($form_state['storage']['machine_name']) && !empty($values['machine_name'])) {
// Move temporary cache to new storage if machine name was changed..
if ($form_state['storage']['machine_name'] != $values['machine_name']) {
$breadcrumb = path_breadcrumbs_object_cache_get($form_state['storage']['machine_name']);
path_breadcrumbs_object_cache_clear($form_state['storage']['machine_name']);
path_breadcrumbs_object_cache_set($values['machine_name'], $breadcrumb);
$form_state['storage']['machine_name'] = $values['machine_name'];
}
}
elseif (isset($values['machine_name'])) {
// Save machina name in form storage.
$form_state['storage']['machine_name'] = $values['machine_name'];
}
// Get current breadcrumbs machine name.
$machine_name = $form_state['storage']['machine_name'];
// Update cache.
$breadcrumb = path_breadcrumbs_object_cache_get($machine_name);
if (empty($breadcrumb)) {
// Initialize cache data.
$breadcrumb = array();
}
// Merge data into cache storage.
$breadcrumb = array_merge((array) $breadcrumb, $values);
path_breadcrumbs_object_cache_set($machine_name, $breadcrumb);
// Switch current step.
if (isset($values['next']) && $values['op'] == $values['next']) {
$form_state['storage']['step']++;
}
elseif (isset($values['prev']) && $values['op'] == $values['prev']) {
$form_state['storage']['step']--;
}
elseif (isset($values['finish']) && $values['op'] == $values['finish']) {
$form_state['rebuild'] = FALSE;
}
$form_state['rebuild'] = TRUE;
}