function Xmodule_builder_page_validate in Module Builder 7
Same name and namespace in other branches
- 6.2 module_builder.module \Xmodule_builder_page_validate()
Makes sure that valid values have been provided to the Module Builder.
Related topics
File
- ./
module_builder.module, line 542 - Builds scaffolding for custom modules.
Code
function Xmodule_builder_page_validate($form, &$form_state) {
# TODO
if ($form_values['op'] == 'input') {
// Ensure module_root_name was entered, and check for special characters
if (!empty($form_values['module_root_name'])) {
if (!preg_match(MODULE_BUILDER_FUNCTION_PATTERN, $form_values['module_root_name'])) {
form_set_error('module_root_name', t('The module root name must only contain letters, numbers, and underscores, and may not start with a number.'));
}
}
// Make sure at least one hook was chosen
$hook_selected = FALSE;
foreach ($form_values['hooks'] as $file => $hooks) {
foreach ($hooks as $hook) {
if ($hook == 1) {
$hook_selected = TRUE;
break;
}
}
if ($hook_selected) {
break;
}
}
if (!$hook_selected) {
form_set_error('hooks', t('You must select at least one hook.'));
}
}
}