Vixen
feb85697
csharp
public sealed class Form

A set of fields that is submitted as one, and refuses to be while any of them is wrong.

Read the guide page for this →

Remarks

The submission half of doc 49 § 7.1's rank 4. LabeledContent is the row and GroupBox the box round a question; neither knows that the rows are sent. Every field here already validates itself — TextField, Select, MultiSelect, ComboBox, CheckBox, RadioGroup and DatePicker each answer IsValid and Revalidate() — and nothing asked all of them at once, so an application's OK button had to know every field it sat under.

⚠ HTML's three submission rules, and each is a place an application used to write the form by hand. Enter in a field that does not want it for a line break submits (implicit submission — heard as the routed SubmitEvent a field raises, so the field decides what Enter means and a text area keeps its line breaks); a click on the form's default button submits; and a submission with a field that will not take its value is refused, the first such field in document order is focused, and every field is marked as having been through a submission — which is what lets a :user-invalid rule match the required field nobody reached, exactly as a browser's does after the first press of Submit.

⚠ A field belongs to the nearest form above it, which is HTML's form owner. A form inside a form — which HTML forbids and a composed panel can still produce — does not validate its inner form's fields, and a submission that started inside the inner one is the inner one's and not also the outer's. A disabled field, or one under a disabled control, is not validated: it is barred from constraint validation, as a disabled <input> is.

⚠ The event is not marked handled. A dialog that closes on its field's Submitted, or an ancestor listening for the routed event, still hears the key; the form's answer is Submitted and Submit's return value, and whether the dialog should have closed on an invalid form is the dialog's question.

What it deliberately is not. It draws nothing and has no title: a form's heading is the panel's, and its accessible name — which makes it a form landmark a screen reader can jump to — is AccessibleName, the property every element already has. It holds no values either; the fields do, bound to the application's model.

Fields and properties (4)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • protected override bool AcceptsFocus
  • protected override AccessibleRole NativeRole
  • public IReadOnlyList<Control> Fields

    The fields this form validates, in document order.

Events (1)

  • public Action<Form>? Submitted

    Raised when a submission is accepted: every field in the form took its value.

Methods (2)

  • public bool Submit()

    Validates every field and, if all of them take their values, raises Submitted.

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

Used by (4)

  • GalleryHelloUi
  • BuiltVixen.Ui.Controls.Tests
  • DatePickerTestsVixen.Ui.Controls.Tests
  • FormTestsVixen.Ui.Controls.Tests