marmelab / ng-admin

Add an AngularJS admin GUI to any RESTful API
http://ng-admin-book.marmelab.com/
MIT License
3.95k stars 726 forks source link

Fields marked as not editable should not be sent to the server on save #808

Open OverZealous opened 8 years ago

OverZealous commented 8 years ago

The issue is we have a bunch of embedded documents that aren't practical to edit from the Admin, so we usually perform some modification via .map, then render using either 'json' or a 'template'.

However, if the .map changes the value in any way, this is sent back to the server on save, even though the field is not editable, resulting in corrupted data. This is pretty unexpected, since the field is not editable, yet the value is being edited (via map).

I'm currently using a few techniques to prevent the issue, but it's pretty tricky, especially when embedded objects are being flattened, so you can't just map them to a fake field.

Alternatively, maybe we need a way to flag fields that shouldn't be sent back.

fzaninotto commented 8 years ago

You're right, marked as bug.

Kmaschta commented 7 years ago

@jpetitcolas explained why we can't address this issue, in the PR #1067

These changes may have some drawbacks. Indeed, some API may expect all the entity fields in the request payload, even the non-editable ones. Yet, as far as I understand your PR, you do not send non editable fields anymore.

That's a big BC break, and I am not sure we handle it properly. A better way would be to retrieve the original entry values and to set them back to the API.

Let's postpone it to another version than the 1.0.