You are here

function notifications_field_parse_submitted in Notifications 6.4

Collect submitted fields and parse new values

2 calls to notifications_field_parse_submitted()
notifications_custom_fields_form in notifications_custom/notifications_custom.admin.inc
Fields form: edit /add fields to custom subscription type
notifications_field_validate_submitted in includes/object.inc
Validate submitted field values and set the new ones as valid array of values

File

includes/object.inc, line 244
Notifications object and fields

Code

function notifications_field_parse_submitted(&$form_state, $element_name = 'fields') {
  $fields = array();
  if (!empty($form_state['values'][$element_name]['type'])) {
    $field_values =& $form_state['values'][$element_name];
    foreach ($field_values['type'] as $key => $type) {

      // If marked for deletion we just keep it there, don't return field
      if (empty($field_values['delete'][$key])) {

        // First collect all field values from the form
        $field = array(
          'type' => $type,
          'value' => $field_values['value'][$key],
          'edit' => $field_values['edit'][$key],
        );

        // Complete field edit value, depending on field definition.
        if (empty($field_values['parsed'][$key])) {
          $value = notifications_field_real_value($type, $field['edit']);
          if (isset($value)) {
            $field['value'] = $value;
            $field_values['value'][$key] = $value;
            $field['parsed'] = TRUE;
            $field_values['parsed'][$key] = TRUE;
          }

          // Otherwise we let the field keep its value
        }

        // Add field to the list and mark as formatted so we can use this value for the form
        $fields[] = $field;
      }
    }
  }
  return $fields;
}