ZodulaZodula
Core

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 required
  • unique - Field value must be unique
  • default - Default value
  • placeholder - Placeholder text
  • readonly - Field is read-only
  • in_list_view - Show in list view

Email

Email input field with validation.

email: {
    type: "Email",
    label: "Email",
    required: 1,
    unique: 1
}

Options:

  • required - Field is required
  • unique - Field value must be unique
  • default - Default value
  • placeholder - Placeholder text

Password

Password input field (hidden text).

password: {
    type: "Password",
    label: "Password",
    required: 1,
    no_copy: 1
}

Options:

  • required - Field is required
  • no_copy - Field cannot be copied
  • placeholder - Placeholder text

Integer

Integer number input field.

age: {
    type: "Integer",
    label: "Age",
    default: "0"
}

Options:

  • required - Field is required
  • default - Default value
  • min - Minimum value
  • max - Maximum value

Float

Decimal number input field.

price: {
    type: "Float",
    label: "Price",
    precision: 2
}

Options:

  • required - Field is required
  • default - Default value
  • precision - Decimal precision
  • min - Minimum value
  • max - 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 required
  • default - Default value (today's date)

Datetime

Date and time picker field.

created_at: {
    type: "Datetime",
    label: "Created At"
}

Options:

  • required - Field is required
  • default - Default value (current datetime)

Time

Time picker field.

start_time: {
    type: "Time",
    label: "Start Time"
}

Options:

  • required - Field is required
  • default - Default value

JSON

JSON data storage field.

metadata: {
    type: "JSON",
    label: "Metadata"
}

Options:

  • required - Field is required
  • default - 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 required
  • options - Newline-separated list of options
  • default - Default selected option
  • in_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 required
  • reference - Target DocType name
  • on_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 label
  • columns - Number of columns (1-3)
  • collapsible - Section can be collapsed
  • defaultCollapsed - 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 required
  • is_public - File is publicly accessible
  • accept - Accepted file types
  • max_size - Maximum file size

Image

Image upload field.

avatar: {
    type: "Image",
    label: "Avatar",
    is_public: 1
}

Options:

  • required - Field is required
  • is_public - Image is publicly accessible
  • max_size - Maximum file size

HTML

Rich text editor field.

content: {
    type: "HTML",
    label: "Content"
}

Options:

  • required - Field is required
  • default - 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 label
  • description - Field description/help text
  • placeholder - Placeholder text
  • in_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 value
  • group - Field group for organization
  • idx - Field index/order

Database Properties

  • on_delete - Action when referenced record is deleted
  • on_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"
})