Skip to main content

Bind a Custom Control to a Field

Goal​

Replace a Model-Driven form field's native editor with a registered Custom Control, so that field renders and edits its value through the control.

Prerequisites​

  • You are signed in as a maker with permission to edit the form's solution.
  • The field you want to use the control on already exists on the entity and is placed on the form.
  • The Custom Control is registered and installed in the environment you are editing (see Register a Custom Control), and its substitutes-for list includes the field's control type.

Steps​

  1. Open the solution, select Tables, open the table, and select Forms. Open the form in the form designer.
  2. Drag the field from Available fields onto a section, or select it if it is already on the form.
  3. In Properties, open Custom Control. It lists the custom controls installed in this environment that can stand in for this field's data type (a control that declares the universal Custom type is offered for any field). None keeps the field's own editor. The Control setting above it chooses between the built-in editors; a custom control replaces whichever one it names.
  4. Choose the control, for example Badge field.
  5. Select Save.

The list only appears when at least one installed control can stand in for the field, so a field that shows no Custom Control setting has nothing to offer it yet.

What happens behind the scenes​

The form records the control's logical name against that field. When a user opens the form in the Model-Driven App Player, the Player resolves the field's control to the control installed in the environment and mounts it in place of the native editor, loading it as a Module Federation remote from an allow-listed origin. The Custom Control receives the field's current value and commits changes back through the same form — so the value the control writes is saved exactly like a value typed into a native field. If the referenced control is not installed in the environment, the field falls back to its native editor rather than breaking the form.

Troubleshooting​

  • The control does not appear in the picker. — the control may not be installed in this environment, or its substitutes-for list may not include this field's control type. Register or reconfigure the control, then reopen the form.
  • The field shows "This control's code is served from a blocked origin". — the control's remoteEntry origin is not on the environment's allow-list. Ask an administrator to add the origin to the environment's allow-list.
  • The field shows its native editor instead of the control after import. — the control was not included in the imported solution or is not yet installed in the target environment. Import the solution that contains the control, then reopen the form.
  • A control's own button fires whenever you click inside it (a signature pad clears as soon as you let go of the mouse). — fixed. The form wrapped each field in a label, and a click anywhere in a label is passed to the first button inside it. A field with a custom control is no longer wrapped that way.
  • Register a Custom Control.
  • Add a field to a form.
  • Create a form.