Skip to main content

GUI-Defined Field Rules

saves you time, ensures consistency, and removes repetitive code

What It Does

For every field in JCB, you can configure rule-based behaviors visually. This avoids hand-coding and ensures your field:

  • Behaves correctly in forms (e.g. required fields trigger validation)
  • Generates accurate database constraints (e.g. unique columns)
  • Applies correct save/load logic for null values or defaults

These GUI-defined rules are enforced during both compilation and runtime, streamlining consistency between what users see and how data is handled in the backend.

Key Rule Options

  • โœ… Required: Marks the field as mandatory in the edit view form. JCB auto-generates validation checks and ensures submission cannot proceed unless the field is filled.
  • ๐Ÿ” Unique: Ensures the fieldโ€™s value is not duplicated across records. JCB injects uniqueness validation logic into the model or controller during compile.
  • ๐Ÿšซ Nullable: Controls whether a database column can accept NULL. When unchecked, the field always stores a default or zero value.
  • ๐ŸŽฏ Default Value: Specify a default for new records. JCB writes this to the SQL schema and loads it into the form unless overridden.
  • ๐Ÿ›ก๏ธ Readonly / Disabled: Useful for fields that should be displayed but not modified in some contexts (e.g., generated slugs, system values).
  • ๐Ÿ” ACL-Aware: Each rule can respect Joomla permissions. You can make fields required only for certain user groups or editable only under specific access conditions.

Where Itโ€™s Configured

  • Inside the Field configuration form (in the Rules/Validation tab)
  • As part of the Field Type definition (to enforce defaults)
  • In View configuration (to override global rules per context)

Use Cases

  • โœ… A required title field on every form
  • โœ… A unique email address field for each user record
  • โœ… A nullable expiration date field with optional input
  • โœ… Setting defaults for boolean switches or dropdowns
  • โœ… Disabling certain fields during record editing based on user group

Conclusion

JCBโ€™s GUI-driven rules framework saves you time, ensures consistency, and removes repetitive code. Whether you're enforcing data integrity or building smart forms, these field-level constraints let you bake business logic right into the structure of your component โ€” visually and declaratively.