Here is the original function.

/**
 * Logic for telling when a field value is required.
 */
function date_is_required($field, $column, $delta, $value1, $value2) {
  if ($column == 'value2' && ($field['todate'] == 'required' && ($value1 || $delta == 0))) {
    return TRUE;
  }
  elseif ($column == 'value' && ($field['required'] || $delta == 0)) {
    return TRUE;
  }
  return FALSE;
}

IMO in the second case when validate the "from date" field, the value of the ($field['required'] && $delta == 0) is logical.
In the actual case I run into a problem. field was validated because of $delta = 0 even if it was not set to required.

Because the form value that I posted was empty a validation is occured on my null value and a form_set_error fired.

patch attached.

CommentFileSizeAuthor
date_required_check.5-1.patch715 bytesenergie

Comments

karens’s picture

Status: Active » Fixed

illogic indeed! You're right, thanks for the patch. Committed to all branches.

Anonymous’s picture

Status: Fixed » Closed (fixed)