fix: In insert/update, skip fields which are not present in the form (except for checkboxes). Closes #2039. (#2041)
fix: In insert/update, skip fields which are not present in the form (except for checkboxes). Closes #2039. (#2041)

* fix: In insert/update, skip fields which are not present in the form (except for checkboxes). Closes #2039.

Slack discussion with @fletch3555: https://laravel-voyager.slack.com/archives/C36H9MY2C/p1508251133000428

When Voyager inserts/updates, it will assume that all fields in $dataType->editRows
or $dataType->addRows will be present in the form.

For file and image fields, this is not an issue by default design because
code to persist files and update records only runs when the file is
present, but for other field types which may or may not be shown the user
based on the role/permission or other custom functionality (like a Weekly Goal
selection, for example, which we only allow users to pick at the start of the week)
the current mechanism will set the field to null, and in the case of
a relation field it will clear out the relation.

With this commit, a column will be updated only if its corresponding field
is present in the request. The exception here being a checkbox which
depending on the browser may or may not show up in the request.

* refactor: Style fix

fletch3555/voyager,the-control-group/voyager,darit/voyager,the-control-group/voyager,darit/voyager,handiwijoyo/voyager,SaadEddinHassania/voyager,SaadEddinHassania/voyager,handiwijoyo/voyager,fletch3555/voyager