Skip to main content

Pre-filled fields

If you want fields to be pre-filled with existing values, pass an initial state dictionary to run:

import my_api
from abstra.forms import NumberInput, TextInput, run

initial_data = my_api.get_data()
# Example: {'name': 'John Doe', 'company': 'ACME'}

personal_details = [
TextInput("First Name", key="name"),
NumberInput("Age", key="age")
]

company_details = [
TextInput("Company", key="company"),
TextInput("Job Title", key="job_title")
]

# Run form with predefined data; missing fields will be left empty
state = run([personal_details, company_details], initial_data)

info
  • Predefined values appear in the form automatically.
  • Any missing data will leave the corresponding input empty for user input.