Squidex
  • Welcome to Squidex
  • Getting Started
    • Squidex Cloud
    • Installation Instructions
      • Platforms
        • Install on Kubernetes
        • Install on AWS (Deprecated)
        • Install on AWS EC2 using Docker
        • Install on Azure
        • Install on Azure using ARM
        • Install on Google Cloud Platform (GCP)
        • Install on Docker
        • Install on Heroku
        • Install on IIS
        • Install on Render
        • Install on Vultr
      • Configuration
        • Deploying the Image Resizer Service
      • Troubleshooting and Support
        • Diagnose Runtime Issues
        • Restoring Deleted Apps
      • Install Identity (Deprecated)
      • External Identity Providers
        • Azure AD (OAuth) with Squidex
    • Contributing and Developing
      • Building
      • Developing
      • Extensions
        • Custom Rule Action
      • Contributing
      • Architecture
      • Translating
      • Squidex Docs Program
    • Roadmap
    • Quick Start Guides
      • Vue.js Blog with Squidex
      • React.js Blog with Squidex
      • Angular Blog with Squidex
  • Documentation
    • Introduction and Use Case
    • Concepts
      • Apps
      • Teams
      • Schemas
        • Field Rules
      • Content
        • Scheduled Publishing
      • Assets
        • Querying Assets
      • Localization
      • Migrations
      • Roles & Permissions
      • Rules
        • Publish an Event to Azure Queues using Rules
        • Populate Elasticsearch Index
      • Backups
      • Subscriptions
        • App Subscriptions v/s Team Subscriptions
      • Notifications
      • Dashboard
      • Workflows
    • Software Development Kits
      • TypeScript
      • .NET
        • Version v14 (and Earlier)
        • Version v15 (and Later)
      • PHP
      • Java
    • Developer Guides
      • API
        • Authentication
        • Postman
        • Queries
        • Assets
      • Automation Tools (CLI)
      • Scripting
        • Scripting Helper Methods
      • Embed Content
      • Custom Workflows
      • Custom Editors
      • Custom Sidebars
      • Preview Content
      • Rule Formatting
        • Simple
        • Script
        • Liquid
      • Tutorials
        • Building a Blog with Squidex and Next.js
  • Next
    • Squidex 3.0: API Compatibility
Powered by GitBook
On this page

Was this helpful?

  1. Documentation
  2. Concepts
  3. Schemas

Field Rules

Learn About Field Rules in Squidex

PreviousSchemasNextContent

Last updated 2 years ago

Was this helpful?

This documentation is based on the FoodCrunch use case. Please open the link below alongside this page to understand the examples.

A Field Rule is a method of implementing automated actions on schema fields when a certain condition is met. It is made up of three components as follows:

  • Action: This component states what should be done when the condition(s) is/are met. It has the following options:

    • Disable

    • Hide

    • Require

  • Field: This relates to when the schema field is selected dependent upon which action should be taken.

  • Condition: Written in Javascript, this action is triggered when the condition is met.

For our FoodCrunch user case let's consider the following example to understand Field Rules. For all startups that are not in Pre-Seed stage, the funding value must be mentioned. It is therefore a required field.

For our use case, the rule is that anytime the value of the Stage field is anything other than Pre-Seed, then the Funding is a required field, otherwise it's optional.

Let's see how to implement this:

  • Ensure that the Validation (2) of the Stage (1) field is set to Required (3) in the settings. This is necessary to make sure that a value is always selected.

  • To create a Field Rule, go to the Schema (1) (i.e. in our case startups), select the More (2) tab, click + (3) under Field Rules and enter the selections for Action, Field and Condition (4). Click Save (5) when done. In our example the following values have been set:

    1. Action = Require

    2. Field = funding

    3. Condition (in Javascript) = data.stage.iv != 'Pre-Seed'

  • This can now be validated by trying to add content. Go to Content and try adding content. Immediately you will find that the stage and funding fields have a red flag.

  • If you set stage as Pre-Seed, the red flag denoting that the funding value is required will disappear, which means its optional.

  • If you set stage as any other value, the red flag remains meaning that a value has to be entered in funding.

Introduction and Use Case
Setting validation for a field
Creating a Field Rule
Fields with rules
Rule validation example 1
Rule validation example 2