You are here

function content_multigroup_fix_element_values in Content Construction Kit (CCK) 6.3

Make sure the '_weight' and '_remove' attributes of the element exist.

See also

content_multigroup_node_form_transpose_elements()

1 string reference to 'content_multigroup_fix_element_values'
content_multigroup_node_form_transpose_elements in modules/content_multigroup/content_multigroup.node_form.inc
Transpose element positions in $form_state for the fields in a multigroup.

File

modules/content_multigroup/content_multigroup.node_form.inc, line 661
Implementation of node edit functions for content multigroup.

Code

function content_multigroup_fix_element_values($element, &$form_state) {
  $field_name = $element['#field_name'];
  $delta = $element['#delta'];
  if (!isset($form_state['values'][$field_name][$delta]['_weight']) || !isset($form_state['values'][$field_name][$delta]['_remove'])) {
    $value = array(
      '_weight' => $element['#_weight'],
      '_remove' => $element['#removed'],
    );
    if (isset($form_state['values'][$field_name][$delta]) && is_array($form_state['values'][$field_name][$delta])) {
      $value = array_merge($form_state['values'][$field_name][$delta], $value);
    }
    form_set_value($element, $value, $form_state);
  }
}