form function

Component form(
  1. List<Component> children, {
  2. String? action,
  3. FormMethod? method,
  4. FormEncType? encType,
  5. AutoComplete? autoComplete,
  6. String? name,
  7. bool? noValidate,
  8. Target? target,
  9. Key? key,
  10. String? id,
  11. String? classes,
  12. Styles? styles,
  13. Map<String, String>? attributes,
  14. Map<String, EventCallback>? events,
})

The <form> HTML element represents a document section containing interactive controls for submitting information.

  • action: The URL that processes the form submission. This value can be overridden by a formaction attribute on a <button>, <input type="submit">, or <input type="image"> element. This attribute is ignored when method="dialog" is set.

  • method: The HTTP method to submit the form with.

    This value is overridden by formmethod attributes on <button>, <input type="submit">, or <input type="image"> elements.

  • encType: If the value of the method attribute is post, enctype is the MIME type of the form submission.

  • autoComplete: Indicates whether input elements can by default have their values automatically completed by the browser. autocomplete attributes on form elements override it on <form>.

  • name: The name of the form. The value must not be the empty string, and must be unique among the form elements in the forms collection that it is in, if any.

  • noValidate: Indicates that the form shouldn't be validated when submitted. If this attribute is not set (and therefore the form is validated), it can be overridden by a formnovalidate attribute on a <button>, <input type="submit">, or <input type="image"> element belonging to the form.

  • target: Indicates where to display the response after submitting the form. In HTML 4, this is the name/keyword for a frame. In HTML5, it is a name/keyword for a browsing context (for example, tab, window, or iframe).

Implementation

Component form(List<Component> children,
    {String? action,
    FormMethod? method,
    FormEncType? encType,
    AutoComplete? autoComplete,
    String? name,
    bool? noValidate,
    Target? target,
    Key? key,
    String? id,
    String? classes,
    Styles? styles,
    Map<String, String>? attributes,
    Map<String, EventCallback>? events}) {
  return DomComponent(
    tag: 'form',
    key: key,
    id: id,
    classes: classes,
    styles: styles,
    attributes: {
      ...attributes ?? {},
      if (action != null) 'action': action,
      if (method != null) 'method': method.value,
      if (encType != null) 'enctype': encType.value,
      if (autoComplete != null) 'autocomplete': autoComplete.value,
      if (name != null) 'name': name,
      if (noValidate == true) 'novalidate': '',
      if (target != null) 'target': target.value,
    },
    events: events,
    children: children,
  );
}