Removing the value from the $formData should work. Setting a key null does not delete from the array. Instead, use unset like this:
foreach ($formData as $key => $value)
{
if ($value == "")
unset( $formData[$key] );
}
This should work.
Please notice here that I'm trying to perform an update of the form (not insert). Unfortunately unsetting an empty field from the array will cause that field to be skipped while updating. So any old value of that field would remain untouched, while I actually want to be able to overwrite old values to NULL.
Sorry, I must have missed the update. In that case setting the value to null should work
$formData[$key] = null;
but like you said I doesn't...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.