function notifications_subscription_list_form_validate in Notifications 6.4
Same name and namespace in other branches
- 7 notifications.module \notifications_subscription_list_form_validate()
Submit list of subscriptions
1 call to notifications_subscription_list_form_validate()
- notifications_user_form_validate in ./
notifications.module - Process generic form submission
File
- ./
notifications.pages.inc, line 732 - User pages for Notifications
Code
function notifications_subscription_list_form_validate($form, &$form_state) {
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : NULL;
switch ($op) {
case t('Add'):
$save_fields = array();
foreach ($form_state['values']['editable_fields'] as $field) {
$type = $field->field;
$key = 'field_' . $type;
$value = isset($form_state['values']['subscriptions'][$key]['new']) ? $form_state['values']['subscriptions'][$key]['new'] : NULL;
if ($real_value = notifications_field_real_value($type, $value)) {
$save_fields[] = array(
'type' => $type,
'value' => $real_value,
);
}
else {
form_set_error("subscriptions][{$key}][new", t('You must set a valid value for this field.'));
}
}
$form_state['values']['parsed_fields'] = $save_fields;
break;
case t('Delete'):
case t('Enable'):
case t('Disable'):
// For this cases check only that we have selected some subscriptions
$selected = array_filter($form_state['values']['subscriptions']['select']);
if (isset($selected['new'])) {
unset($selected['new']);
unset($form_state['values']['subscriptions']['select']['new']);
}
if (!$selected) {
//count($selected) < 1) {
form_set_error('', t('You must select some subscriptions for that operation.'));
}
break;
}
}