Skip to content

Commit

Permalink
Fix fatal error when saving a form with a protected date field that i…
Browse files Browse the repository at this point in the history
…s null.
  • Loading branch information
campbell-m committed Nov 23, 2023
1 parent ce808b1 commit 3e0bd34
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions web/edit_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -1132,17 +1132,14 @@ function get_fieldset_submit_buttons(?int $user_id, $delete=false, $disabled=fal
// we assume that the user is trying to nullify the value.
if ($field['type'] == 'date')
{
if (!validate_iso_date($values[$field['name']]))
if ($field['is_nullable'] && (!isset($values[$field['name']]) || ($values[$field['name']] === '')))
{
if ($field['is_nullable'] && ($values[$field['name']] === ''))
{
$values[$field['name']] = null;
}
else
{
$valid_data = false;
$q_string .= "&invalid_dates[]=" . urlencode($field['name']);
}
$values[$field['name']] = null;
}
elseif (!validate_iso_date($values[$field['name']]))
{
$valid_data = false;
$q_string .= "&invalid_dates[]=" . urlencode($field['name']);
}
}
}
Expand Down

0 comments on commit 3e0bd34

Please sign in to comment.