public static function Notifications_Subscription::validate_submission in Notifications 6.4
Same name and namespace in other branches
- 7 notifications.subscription.inc \Notifications_Subscription::validate_submission()
Validate form submission
1 call to Notifications_Subscription::validate_submission()
- notifications_subscription_base_form_validate in ./
notifications.pages.inc - Validate subscription
File
- includes/
notifications_subscription.class.inc, line 136 - Drupal Notifications Framework - Default class file
Class
- Notifications_Subscription
- Message destination class
Code
public static function validate_submission(&$form_state) {
// The object may be already created ir it may be an array so we use this function that handles that
$subscription = notifications_build_subscription($form_state['values']['subscription']);
// There may be optional fields to add
if (!empty($form_state['values']['subscription_fields'])) {
foreach ($form_state['values']['subscription_fields'] as $field) {
if (isset($form_state['values'][$field])) {
$field_value = $form_state['values'][$field];
switch ($field) {
case 'fields':
notifications_include('object.inc');
foreach ($field_value as $key => $field_values) {
if ($value = notifications_field_real_value($field_values['type'], $field_values['edit'])) {
$form_state['values']['parsed_fields'][$key] = array(
'type' => $field_values['type'],
'value' => $value,
);
}
else {
form_set_error("{$field}]['edit", t('Invalid value for this field.'));
break;
}
}
break;
case 'send_method':
// There may be other destination validation running that sets the destination object before
if (empty($form_state['values']['destination']) && (!$subscription->mdid || $subscription->send_method != $field_value)) {
if ($subscription
->validate_destination($field_value)) {
$form_state['values']['subscription_fields'][] = 'destination';
}
else {
form_set_error('send_method', t('Cannot create a valid destination.'));
}
}
break;
}
}
}
}
}