Skip to main content

Field Types Define Templates and Data Types

the building blocks of your componentโ€™s logic and data structure

What It Means

In JCB, field types are more than just form inputs โ€” they are blueprint-driven entities that define how data is stored, validated, rendered, and interacted with. Each field type encapsulates both database schema and frontend/backend behavior, offering maximum reusability and consistency across views.

What It Is

Every field you create in JCB is based on a field type, which acts as a pre-configured template that dictates:

  • The fieldโ€™s data type (e.g., INT, VARCHAR, JSON, DATE)
  • How it is rendered (text input, select box, calendar, etc.)
  • What database structure it requires
  • What validation and logic it applies during save/load
  • Whether itโ€™s editable, required, unique, nullable, etc.

JCB ships with dozens of Joomla-native field types and lets you define custom field types tailored to your componentโ€™s needs.

Key Features

  • ๐Ÿ“ Structured Templates: Field types define the HTML and PHP rendering for each view (list/edit, admin/config), including layout and wrapper logic.
  • ๐Ÿง  Central Rule Engine: Rules such as required, unique, readonly, default value, etc., are defined per field type and automatically applied wherever used.
  • ๐Ÿ“ฆ Consistent DB Schema: Fields derived from a field type automatically create matching SQL columns when compiled (unless overridden).
  • ๐Ÿ”ง Reusable and Customizable: Field types can be reused across multiple views, components, or even exported/imported via blueprints.
  • ๐Ÿ” Version-Aware Updates: JCB tracks field type changes and allows for safe resets, forks, or field type inheritance.
  • ๐ŸŒ Joomla Compatibility: All native Joomla field types are supported and extended: text, select, calendar, editor, subform, repeatable, etc.

When You Use It

  • Creating a new form field in a view
  • Defining backend config fields or frontend submission forms
  • Sharing complex input types (e.g., repeatable subforms, JSON maps)
  • Linking fields to subviews or custom admin logic
  • Implementing auto-validation on save

Use Cases

  • โœ… A โ€œSlugโ€ field with unique + lowercase constraints
  • โœ… A โ€œSubregion selectorโ€ based on another viewโ€™s data
  • โœ… A repeatable calendar field using subform
  • โœ… A multiselect JSON-tag field for frontend filters
  • โœ… A WYSIWYG editor only visible in Joomla 5

Best Practices

  • Define new field types for any logic or structure used more than once
  • Group similar field types using the Tags field inside JCB
  • Use dynamic placeholders in rendering logic to adapt per context
  • Leverage the field preview system when testing render logic

Conclusion

Field types are the building blocks of your componentโ€™s logic and data structure. JCB transforms them into fully automated renderers, validators, and schema generators โ€” letting you control everything from user input to database schema with one powerful abstraction. Create once, reuse forever.