MentorAgent Docs
Menu

Questa pagina non è ancora tradotta in italiano: qui la trovi in inglese.

RiferimentoPacchetto: Novior.MentorAgent.Abstractions

MentorFormExtensions class

The MentorFormExtensions class of Novior.MentorAgent.Abstractions.Interfaces: A page's form as a UI action the model can fill: fill_<form>, with the fields…

In questa pagina

A page's form as a UI action the model can fill: fill_<form>, with the fields to fill as its parameter. The action fills the fields, as the user would type them, and never submits the form: sending it stays an action of the application's own, with its confirmation if it writes.

Namespace: Novior.MentorAgent.Abstractions.Interfaces. Package: Novior.MentorAgent.Abstractions.

public static class MentorFormExtensions

Terminal
dotnet add package Novior.MentorAgent.Abstractions

public static IMentorPageContext RegisterForm<TModel>(this IMentorPageContext page, string name, string description, IJSRuntime js, Action<MentorFormOptions>? configure = null)

Registers the form whose model is TModel as the UI action fill_<name>.

The fields are the public properties of TModel with a getter and a setter, of a simple type: text, number, Boolean (a checkbox), an enum (a select, whose options read the enum's names), Guid, a date or a time. Each field is found in the page by its data-mentor-id, "<name>.<field>", the field written as the model sees it (customerName), unless MentorFormOptions.Selector gives another selector.

A sensitive field is never offered unless MentorFormOptions.IncludeSensitive names it: a property with [DataType(DataType.Password)], [DataType(DataType.CreditCard)] or [PasswordPropertyText], or whose name says it holds a password, a secret, a token, a PIN, a card's number or code, an IBAN or a one-time code. In the page, a password field is never written either, whatever its property.

The steps run in the browser through js, the page's own IJSRuntime: on Blazor Server, WebAssembly and MAUI Hybrid alike. A field that is not in the page, hidden, disabled, inside data-mentor-exclude or a password field fails the action, which the gate reports as failed.

Parameters

  • page: The page's context.
  • name: The form's name: letters, digits, _ and -; the action is fill_<name>.
  • description: What the form is, for the model and for the decisions ("The new order's form").
  • js: The page's JavaScript runtime (@inject IJSRuntime JS).
  • configure: Fields left out, sensitive fields let in, selectors of the page's own.