Field Types
Field Types
Field Types
Zodula supports various field types for different data needs. Each field type has specific configuration options and behaviors.
Basic Field Types
Text
Single-line text input field.
name: {
type: "Text",
label: "Name",
required: 1,
unique: 1
}Options:
required- Field is requiredunique- Field value must be uniquedefault- Default valueplaceholder- Placeholder textreadonly- Field is read-onlyin_list_view- Show in list view
Email input field with validation.
email: {
type: "Email",
label: "Email",
required: 1,
unique: 1
}Options:
required- Field is requiredunique- Field value must be uniquedefault- Default valueplaceholder- Placeholder text
Password
Password input field (hidden text).
password: {
type: "Password",
label: "Password",
required: 1,
no_copy: 1
}Options:
required- Field is requiredno_copy- Field cannot be copiedplaceholder- Placeholder text
Integer
Integer number input field.
age: {
type: "Integer",
label: "Age",
default: "0"
}Options:
required- Field is requireddefault- Default valuemin- Minimum valuemax- Maximum value
Float
Decimal number input field.
price: {
type: "Float",
label: "Price",
precision: 2
}Options:
required- Field is requireddefault- Default valueprecision- Decimal precisionmin- Minimum valuemax- Maximum value
Check
Boolean checkbox field.
is_active: {
type: "Check",
label: "Is Active",
default: "1"
}Options:
default- Default value ("1" for checked, "0" for unchecked)in_list_view- Show in list view
Date
Date picker field.
birth_date: {
type: "Date",
label: "Birth Date"
}Options:
required- Field is requireddefault- Default value (today's date)
Datetime
Date and time picker field.
created_at: {
type: "Datetime",
label: "Created At"
}Options:
required- Field is requireddefault- Default value (current datetime)
Time
Time picker field.
start_time: {
type: "Time",
label: "Start Time"
}Options:
required- Field is requireddefault- Default value
JSON
JSON data storage field.
metadata: {
type: "JSON",
label: "Metadata"
}Options:
required- Field is requireddefault- Default JSON value
Advanced Field Types
Select
Dropdown selection field.
priority: {
type: "Select",
label: "Priority",
options: "Low\nMedium\nHigh",
default: "Medium"
}Options:
required- Field is requiredoptions- Newline-separated list of optionsdefault- Default selected optionin_list_view- Show in list view
Reference
Link to another DocType.
user: {
type: "Reference",
label: "User",
reference: "zodula__User",
required: 1
}Options:
required- Field is requiredreference- Target DocType nameon_delete- Action on delete (CASCADE, SET NULL, etc.)on_update- Action on update (CASCADE, SET NULL, etc.)
VirtualReference
Virtual reference to another DocType.
parent_workspace: {
type: "VirtualReference",
label: "Parent Workspace",
reference: "zodula__Workspace"
}Options:
reference- Target DocType name
Tab
Tab container for organizing fields.
basic_info_tab: {
type: "Tab",
label: "Basic Information"
}Options:
label- Tab label
Section
Collapsible section container.
field_config_section: {
type: "Section",
label: "Field Configuration",
columns: 2,
collapsible: 1,
defaultCollapsed: 0
}Options:
label- Section labelcolumns- Number of columns (1-3)collapsible- Section can be collapseddefaultCollapsed- Section is collapsed by default
File
File upload field.
attachment: {
type: "File",
label: "Attachment",
is_public: 1,
accept: ".pdf,.doc,.docx"
}Options:
required- Field is requiredis_public- File is publicly accessibleaccept- Accepted file typesmax_size- Maximum file size
Image
Image upload field.
avatar: {
type: "Image",
label: "Avatar",
is_public: 1
}Options:
required- Field is requiredis_public- Image is publicly accessiblemax_size- Maximum file size
HTML
Rich text editor field.
content: {
type: "HTML",
label: "Content"
}Options:
required- Field is requireddefault- Default HTML content
Field Properties
All field types support these common properties:
Validation Properties
required- Field is required (1 or 0)unique- Field value must be unique (1 or 0)readonly- Field is read-only (1 or 0)only_create- Field can only be set during creation (1 or 0)allow_on_submit- Field can be modified on submit (1 or 0)
Display Properties
label- Field labeldescription- Field description/help textplaceholder- Placeholder textin_list_view- Show in list view (1 or 0)no_copy- Field cannot be copied (1 or 0)no_print- Field is not printed (1 or 0)
Data Properties
default- Default valuegroup- Field group for organizationidx- Field index/order
Database Properties
on_delete- Action when referenced record is deletedon_update- Action when referenced record is updated
Field Layout
Tabs
Use Tab fields to organize fields into separate tabs:
export default $doctype({
basic_info_tab: {
type: "Tab",
label: "Basic Information"
},
name: {
type: "Text",
label: "Name",
required: 1
},
email: {
type: "Email",
label: "Email",
required: 1
},
advanced_tab: {
type: "Tab",
label: "Advanced"
},
metadata: {
type: "JSON",
label: "Metadata"
}
})Sections
Use Section fields to group related fields:
export default $doctype({
personal_section: {
type: "Section",
label: "Personal Information",
columns: 2,
collapsible: 1
},
first_name: {
type: "Text",
label: "First Name"
},
last_name: {
type: "Text",
label: "Last Name"
}
})Examples
User DocType
export default $doctype<"zodula__User">({
name: {
type: "Text",
in_list_view: 1
},
email: {
type: "Email",
required: 1,
unique: 1,
in_list_view: 1
},
password: {
type: "Password",
required: 1,
no_copy: 1
},
is_active: {
type: "Check",
default: "1",
in_list_view: 1
}
}, {
label: "User",
search_fields: "email\nname\nid"
})Product DocType
export default $doctype({
name: {
type: "Text",
label: "Product Name",
required: 1,
in_list_view: 1
},
description: {
type: "HTML",
label: "Description"
},
price: {
type: "Float",
label: "Price",
precision: 2,
required: 1
},
category: {
type: "Reference",
label: "Category",
reference: "Product Category",
required: 1
},
is_available: {
type: "Check",
label: "Is Available",
default: "1",
in_list_view: 1
},
images: {
type: "Image",
label: "Product Images",
is_public: 1
}
}, {
label: "Product",
search_fields: "name\ndescription"
})
Zodula