Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Feature Request: allow using factory function as defaultValue for fields #59

Open
KonstantinYegupov opened this issue Dec 16, 2015 · 0 comments

Comments

@KonstantinYegupov
Copy link

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: #54

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant