function _path_breadcrumbs_ui_form_apply_default_values in Path Breadcrumbs 7.2
Same name and namespace in other branches
- 7.3 path_breadcrumbs_ui/path_breadcrumbs_ui.module \_path_breadcrumbs_ui_form_apply_default_values()
Add default values to form if presented.
Parameters
$form: Form to which values will be applied from cache.
$machine_name: Machine name of breadcrumbs
2 calls to _path_breadcrumbs_ui_form_apply_default_values()
- _path_breadcrumbs_ui_form_step_basic_settings in path_breadcrumbs_ui/
path_breadcrumbs_ui.module - FIRST STEP. Provide form with basic settings.
- _path_breadcrumbs_ui_form_step_breadcrumbs_settings in path_breadcrumbs_ui/
path_breadcrumbs_ui.module - FOURTH STEP. Provide form for breadcrumb settings.
File
- path_breadcrumbs_ui/
path_breadcrumbs_ui.module, line 839 - Provide user interface for CRUD operations with path breadcrumbs.
Code
function _path_breadcrumbs_ui_form_apply_default_values(&$form, $machine_name) {
// Load breacrumb from cache by machine_name.
$breadcrumb = path_breadcrumbs_object_cache_get($machine_name);
if (empty($breadcrumb)) {
return;
}
// Try to apply values from cache to form.
foreach ($form as $key => $value) {
if (!empty($breadcrumb->{$key}) && is_array($breadcrumb->{$key})) {
foreach ($breadcrumb->{$key} as $array_key => $value) {
$form[$key][$array_key]['#default_value'] = $value;
}
}
elseif (!empty($breadcrumb->{$key})) {
$form[$key]['#default_value'] = $breadcrumb->{$key};
}
}
}