Make a field required/not required based on condition in serenity-platform

841 views Asked by At

I am working on a serenity platform project. Any idea how can I make the field required/not required based on a condition inside AbcDialog.ts file. Thanks

3

There are 3 answers

1
kilroyFR On

In the updateInterface() in your dialog.ts you can write TypeScript code to show/hide conditionally some fields like this:

protected updateInterface() {
  super.updateInterface();

  if (this.entity.Status === Enums.RomTicketingStatus.Validated) {
    if (dateOperatingStartDate > dateMin) {
      this.toolbar.findButton('undo-delete-button').show();
    }
  }
}
0
Deowan Faruque Ahamad On

Serenity.EditorUtils.setRequired(this.form.SomeField, yourCondition);

0
Waqar Kabir On
  1. Use the [Required] attribute on your form field for implementation.
  2. In the AbcDialog.ts file, override the function onDialogOpen() and put your logic of required/not required in it.