Search code examples
admin-on-rest

admin-on-rest: How to set the value of a TextField with an option selected in a DefaultOptionsField


I have a SimpleForm within an EditView, where the SimpleForm contains a DefaultOptionsField and a TextField.

The idea is to select an option in the DefaultOptionsField, which then updates the value of the TextField.

I can make this work by updating the TextField on DefaultOptionsField onChange using basic JavaScript, but I would prefer a more Admin-on-Rest and React-like way to set the TextField's value. Yet somehow the EditView layer seems to complicate things for me - I have yet to find a simple, clean and elegant way to make the TextField and DefaultOptionsField interact in that vein.

Is there maybe some basic example code of how I might structure such a solution within Admin-on-Rest?


Solution

  • Your use case pretty much describes AOR Dependent input. Check it out here

    https://github.com/marmelab/aor-dependent-input