function module_data_from_form in Module Builder 7.2
Same name and namespace in other branches
- 6.2 includes/module_builder.pages.inc \module_data_from_form()
- 7 includes/module_builder.pages.inc \module_data_from_form()
Helper function: creates an array of all the data needed to build the module from form values, suitable for passing to Generate::generateComponent().
File
- includes/
module_builder.pages.inc, line 356 - Menu callback for main module builder page.
Code
function module_data_from_form($form, $form_values, $component_data_info) {
// Most things come in as we want them from the form.
$module_data = $form_values;
// Hooks need flattening.
$module_data['hooks'] = array();
foreach ($form_values['hooks'] as $hook_group) {
$module_data['hooks'] += array_keys(array_filter($hook_group));
}
// Build list.
// The UI always gets the full code.
$module_data['requested_build'] = array(
'code' => TRUE,
'info' => TRUE,
);
// Generic processing.
foreach ($component_data_info as $property_name => $property_info) {
// Skip hooks, they got handled specially.
if ($property_name == 'hooks') {
continue;
}
if ($property_info['format'] == 'array') {
if (isset($property_info['options'])) {
// Anything with options needs to have the crud filtered out.
$module_data[$property_name] = array_filter($module_data[$property_name]);
}
else {
// Textareas need splitting on newlines into arrays.
$module_data[$property_name] = preg_split("@\\s*\n\\s*@", $module_data[$property_name], -1, PREG_SPLIT_NO_EMPTY);
}
}
}
return $module_data;
}