function domain_source_validate_domain_nodes_form in Domain Access 7.3
Validates default source selections.
2 string references to 'domain_source_validate_domain_nodes_form'
- domain_source_form_domain_nodes_form_alter in domain_source/
domain_source.module - Implements hook_form_FORM_ID_alter().
- domain_source_form_node_type_form_alter in domain_source/
domain_source.module - Implements hook_form_FORM_ID_alter().
File
- domain_source/
domain_source.module, line 385 - Creates a source domain for linking to content from other domains.
Code
function domain_source_validate_domain_nodes_form($form, &$form_state) {
// Handle the differences between our form and the node type form.
$source = '';
if (isset($form_state['values']['type'])) {
$types = array(
$form_state['values']['type'] => node_type_get_name($form_state['values']['type']),
);
$source = 'node_type_form';
}
else {
$types = node_type_get_names();
}
foreach ($types as $type => $name) {
$item = 'domain_node_' . $type;
$key = 'domain_source_' . $type;
// Using the content type form requires specific form element names.
if ($source == 'node_type_form') {
$item = 'domain_node';
$key = 'domain_source';
}
$value = $form_state['values'][$key];
// Use active is always valid.
if ($value == DOMAIN_SOURCE_USE_ACTIVE) {
continue;
}
$parent = $form_state['values'][$item];
// Any assignment is acceptable if sent to all affiliates.
if (!empty($parent['DOMAIN_ALL'])) {
continue;
}
// Else, we must select the source domain as an option.
if (empty($parent[$value])) {
form_set_error('domain_source_' . $type, t('The default %name source domain must be selected as a default publishing option.', array(
'%name' => $name,
)));
}
}
}