Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

The UI Framework code is being transitioned to a module. Documentation will move to UI Framework.

Usage

Usage
${ ui.includeFragment("widgets/field", [ class: org.openmrs.Role.class, formFieldName: "role"]) }
    // will delegate to (i.e. include) the "fields/org.openmrs.Role" fragment

How to write a field

  • Create a fragment under the "fields" folder as "the.package.ClassName". (TODO where would you put the controller?).
  • Do not implement a label (so that one may be added by the labeledField widget)
  • Do include a span to display errors with id "${ id }-error"

Your field should expect that it may be included in a "form" of some sort. If this is the case, you can count on "parentFormId" being set in the fragment configuration.

If config.parentFormId is set, then your field must listen for these messages, and behave appropriately:

  • "${ config.parentFormId }.reset"
    • -> your field should clear its value and any error messages it is currently displaying
  • "${ config.parentFormId }.clear-errors"
    • -> your field should clear any error messages it is currently displaying ** TODO why do we need this?
  • "${ config.parentFormId }/${ config.formFieldName }.show-errors
    • includes an array of string error messages as its payload
    • -> your field should display the given errors in its error span
  • No labels