Skip to main content
Error Showing Content - please login as admin for details.
Error Showing Content - please login as admin for details.

Formulas Tutorials

Tutorial Home

Formulas affecting Field Settings

We'll show you examples where formulas can be applied to change visibility, required, and more.

In this tutorial you'll learn how to:

  • Change field and group visibility
  • Make fields required
  • Make fields disabled
  • and much more...

Important: The feature "Public Use of Edit Form" is disabled

The feature is needed for anonymous users to use the Edit Form. Register your site here https://patrons.2sxc.org/ to get access to the feature.

Single Field visibility

    This formula determines the visibility of the Description field. It only becomes visible when the Title field isn't empty.
    Click on the (Σ) button above to see the edit-UI with the formula.

    Formulas of FormulasBasic.Description

    Setting Visible (Formula-Target: Field.Settings.Visible)

    v1(data, context) {
      // Show the field when the title isn't empty any more
      return data.Title != "";
    }

    Required fields

      This formula determines wether the Name field is required. It becomes required if the age isn't specified.
      Click on the (Σ) button above to see the edit-UI with the formula.

      Formulas of FormulasRequired.Name

      Field.Settings.Required (Formula-Target: Field.Settings.Required)

      function v1 (data, context) {
        // If we don't have an age, make the name required
        var ok = !data.Age;
        return ok;
      }

      Disabled fields

        This formula determines wether the ApiKeyV2 field is disabled. It becomes disabled if the UseNewFeatures field is true.
        Click on the (Σ) button above to see the edit-UI with the formula.

        Formulas of FormulasDisabled.ApiKeyV2

        Setting Disabled (Formula-Target: Field.Settings.Disabled)

        function v1 (data, context) {
          return data.UseNewFeatures == true;
        }

        Warnings and Errors based on Value

          This formula shows a warning if a field has upper case letters, and an error if empty.
          Click on the (Σ) button above to see the edit-UI with the formula.

          Formulas of FormulasValidation.Title

          Field.Validation (Formula-Target: Field.Validation)

          function v1 (data, context) {
            const t = data.Title;
            console.log('Title at start', t);
            
            // Check if empty
            if (t == null || (/^\s*$/).test(t))
              return { severity: 'error', message: 'this needs real text'};
            // Show warning if not all lower case
            if (data.Title.toLowerCase() !== data.Title)
              return { severity: "warning", message: "we suggest to use lower case only."}
            return data.value;
          }