0

I have an edit form where I require some extra fields like confirm_password, but my server doesn't accept these fields. Also there can be certain cases where I want to transform the keys of the form values to something else as required by my server. How would one do these transformations?

1 Answers1

2

One option would be https://marmelab.com/admin-on-rest/Inputs.html#transforming-input-value-tofrom-store.

The other one would be to handle the transformation, exclusion, whatever, in a custom client

Gildas Garcia
  • 6,966
  • 3
  • 15
  • 29
  • 1
    The problem here would be transformation of keys and deletion of keys. Example: I do not want my confirm_password field to go in request or I might want to fetch with key name `type` while post with field name `type2`. – anuragagarwal561994 Jun 23 '17 at 07:30
  • Custom client it is then. Just clean your object before sending it to your back-end however you like – Gildas Garcia Jun 24 '17 at 10:41
  • But the rules might change for different requests, will it make sense to do this job at client. – anuragagarwal561994 Jun 28 '17 at 20:27
  • The aor-client receives the action type, the resource and the parameters. Nothing prevent you to extract the request transformation logic to an external function – Gildas Garcia Jul 05 '17 at 18:30
  • Could you explain your use case ? – Gildas Garcia Jul 05 '17 at 18:31
  • Take the example of a login form, now the input required for the login form needs to have field such as confirm password but the backend API has no use for this attribute, confirm password validation can be done at frontend only. This type of form or request won't be needed in rest of the application. – anuragagarwal561994 Jul 07 '17 at 08:06
  • Then isn't it the job of you custom client to remove unnecessary data from the request payload ? – Gildas Garcia Jul 25 '17 at 10:03