admin-config icon indicating copy to clipboard operation
admin-config copied to clipboard

Feature Request: allow using factory function as defaultValue for fields

Open KonstantinYegupov opened this issue 10 years ago • 0 comments

Currently, field can have a specified defaultValue to be used during entity creation. However, defaultValue can only be a constant. This makes it impossible to use client-side auto-generated defaults.

While server-generated defaults are more secure in general, client-side ones can have some benefits.

An example can be found in ng-admin sources: https://github.com/marmelab/ng-admin/blob/bd734ba347add0c2aed6ab995585fb723b04cbd7/examples/blog/config.js#L295

Here, the "created_at" field is being preset with a timestamp. However, the timestamp is created incorrectly, new Date() is instantiated during the start of client application, not during the creation of the record, so all the records created during this admin section would have the same date value.

Other possible use cases include auto-generated IDs and passwords. Generating them at client would allow the admin to record or tweak them before saving the data to server.

Pull-request to implement the feature: https://github.com/marmelab/admin-config/pull/54

KonstantinYegupov avatar Dec 16 '15 13:12 KonstantinYegupov