function _path_breadcrumbs_ui_form_step_basic_settings_validate 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_step_basic_settings_validate()
Validate function for basic settings form (first step).
_state
Parameters
$form:
1 string reference to '_path_breadcrumbs_ui_form_step_basic_settings_validate'
- _path_breadcrumbs_ui_form_step_basic_settings in path_breadcrumbs_ui/
path_breadcrumbs_ui.module - FIRST STEP. Provide form with basic settings.
File
- path_breadcrumbs_ui/
path_breadcrumbs_ui.module, line 386 - Provide user interface for CRUD operations with path breadcrumbs.
Code
function _path_breadcrumbs_ui_form_step_basic_settings_validate(&$form, &$form_state) {
$path = explode('/', $form_state['values']['path']);
$correct_path = array();
foreach ($path as $position => $bit) {
if (!($trimmed_bit = trim($bit))) {
continue;
}
// Correct some mistakes that user might make.
$correct_path[] = $trimmed_bit;
if ($trimmed_bit[0] == '%' && $position == 0) {
form_error($form['path'], t('The first element in a path may not be dynamic.'));
}
}
// Save correct path.
$form_state['values']['path'] = implode('/', $correct_path);
$args = array();
foreach ($correct_path as $position => $bit) {
if ($bit[0] == '%' && drupal_strlen($bit) === 1) {
form_error($form['path'], t('Invalid arg <em>%</em>. All arguments must be named with keywords.'));
}
elseif ($bit[0] == '%') {
$args[substr($bit, 1)]['position'] = $position;
}
}
$form_state['values']['keywords'] = $args;
}