LogoLogo
  • What is UDML?
  • Document structure
    • <components>
    • <imports>
    • <instructions>
    • <meta>
    • <styles>
    • <tokens>
    • <mappings>
    • <screens>
  • Directives
    • ai-hint
    • <data> Directive Specification
    • <interaction> Directive
    • <layer> Directive
    • <repeat> Directive
    • <responsive>
    • selection
    • <tracking> Directive
  • Components
    • Layout
      • <accordion> Component
      • <box> Component
      • <column> Component
      • <divider>
      • <grid> Component
      • <row> Component
    • Navigation
      • <breadcrumbs> Component
      • <pagination> Component
      • <tab> Component
      • <tabs> Component
    • Text & Display
      • <avatar>
      • <heading>
      • <icon>
      • <image>
      • <label>
      • <text>
      • <video>
    • Controls & Input
      • <button>
      • <checkbox>
      • <input> Component
      • <radio>
      • <select>
      • <slider>
      • <stepper>
      • <switch>
      • <textarea>
    • Forms
      • <form> Component
      • <formField> Component
      • <formGroup> Component
    • Data Collections
      • <dataColumn> Component
      • <dataTable> Component
      • <list> Component
      • <timeline> Component
      • <treeView> Component
    • Data Visualization
      • <chart> Component
      • <summary> Component
    • Modals
      • <dialog> Component
      • <modal> Component
      • <popover> Component
      • <toast> Component
      • <tooltip> Component
  • Prompting Guides
    • Prompting AI Developer Tools with UDML
    • Working with UDML in an Existing Codebase
  • Contributing to UDML
Powered by GitBook
On this page
  • The <form> component serves as a container for form elements, providing form-level functionality like validation, submission handling, and state management. It can automatically generate appropriate form structure, validation, and submission logic based on its contents.
  • 🛠 Attributes
  • Form State Attributes
  • ✅ Allowed Content
  • 💡 Examples
  • 🧩 AI Interpretation Guidelines
Edit on GitHub
  1. Components
  2. Forms

<form> Component

The <form> component serves as a container for form elements, providing form-level functionality like validation, submission handling, and state management. It can automatically generate appropriate form structure, validation, and submission logic based on its contents.

🛠 Attributes

Attribute
Type
Required
Description

name

string

Yes

Unique identifier for the form

action

string

No

URL endpoint for form submission

method

string

No

HTTP method (post, get)

submitLabel

string

No

Label for auto-generated submit button

validate

boolean

No

Enable automatic validation

autoSubmit

boolean

No

Submit on valid input

resetOnSubmit

boolean

No

Clear form after successful submission

ai-hint

string

No

Natural language description of form purpose

Form State Attributes

These attributes can be used within the form to access form state:

Attribute
Type
Description

formState

object

Current form values

formErrors

object

Current validation errors

isValid

boolean

Form validation status

isSubmitting

boolean

Submission status

✅ Allowed Content

  • Form input components

  • Layout components

  • Validation messages

  • Submit/reset buttons

💡 Examples

Basic Form with Validation

<form name="login" validate="true">
  <column gap="16px">
    <input 
      name="email" 
      type="email" 
      required 
      placeholder="Email"
    />
    <input 
      name="password" 
      type="password" 
      required 
      placeholder="Password"
    />
    <button type="submit">Login</button>
  </column>
</form>

Complex Form with State

<form 
  name="userProfile" 
  validate="true"
  autoSubmit="true"
  resetOnSubmit="true"
>
  <column gap="24px">
    <text>User Profile</text>
    
    <input 
      name="name" 
      required 
      placeholder="Full Name"
    />
    
    <input 
      name="email" 
      type="email" 
      required 
      placeholder="Email"
    />
    
    <select name="role" required>
      <option value="">Select Role</option>
      <option value="admin">Administrator</option>
      <option value="user">User</option>
    </select>
    
    <!-- Show error message if form has errors -->
    <text if="formErrors" color="error">
      Please fix the errors above
    </text>
    
    <!-- Disable submit button while submitting -->
    <button 
      type="submit" 
      disabled="isSubmitting"
    >
      Save Profile
    </button>
  </column>
</form>

🧩 AI Interpretation Guidelines

  • Generate appropriate form element with method and action

  • Create form state management (React state, Vue data, etc.)

  • Implement validation logic based on input attributes

  • Handle form submission and reset

  • Generate appropriate error handling

  • Create accessibility attributes

  • Implement proper form structure and semantics


PreviousFormsNext<formField> Component

Last updated 2 months ago