vendredi 13 février 2015

Creating a custom field type with JSONForm to allow "other" in checkbox selection options

I'm currently building a JavaScript form rendering solution that relies on JSONForm. In the course of reading the documentation, I've found no direct solution for implementing a check box array that includes an option labeled "Other". Ultimately, I need the ability to add an "Other" option, which then opens a text input that the user can enter their custom option into. Some of the problems I'm running into are:



  1. How will I wire up the grouping of these fields so that when the user checks the "Other" box, it automatically opens the previously-hidden text input box and accepts the user input for storage in the JSONForm "values" object?

  2. How will I dynamically link these two items so that when the form is later rendered from the previously filled-out schema, the text box will be shown and pre-populated with the previously entered value, while hiding the text box entirely if the text value is null?


This is a dynamically-generated form tool with "n"-number of fields, so it isn't an option to "hard-code" the interaction... this will (ideally) be a solution that is reusable and extendable.


Please note that I would prefer (if possible) to avoid editing the JSONForm tool itself, as we'd like to be able to drop in newer versions of the core module without making additional edits. My take on this problem is that it's likely solvable using custom field types, but I'm having trouble wrapping my head around precisely how that might work.


Thanks. =)





Aucun commentaire:

Enregistrer un commentaire