Skip to content

Checkbox

Checkbox element is an input with checkbox type. It is similar to SwitchCheckbox element. They differ in appearance.

checkbox

Build-in Validators

Element has one build-in validator - checks if value equals 0 or 1.

Available Validators

Element does not have available validators.

Relations Support

Element supports relations between elements.

Configuration output schema

schema
{
  "<element_type>" : "checkbox",
  "<element_name>" : string,
  "<element_label>" : string,
  "<element_labelDescription>" : string,
  "<element_isRequired>" : bool,
  "<element_isHidden>" : bool,
  "<element_defaultValue>" : int
}
example
{
    "type": "checkbox",
    "name": "shouldShowAuthor",
    "label": "Author of the entry",
    "defaultValue": 0
}

Element value

If value is filled it can be 0 or 1.

usage in module TWIG
{% if moduleConfig.shouldShowAuthor %}
    <li class="blog-article-details__item">
        {{ translate('author') }}: <span class="blog-article-details__detail">AUTHOR</span>
    </li>
{% endif %}

Example of module

Twig

Twig
<ul class="blog-article-details">
    {% if moduleConfig.shouldShowAuthor and article.author %}
        <li class="blog-article-details__item">
            {{ translate('author') }}: <span class="blog-article-details__detail">{{ article.author }}</span>
        </li>
    {% endif %}
</ul>

JSON configuration

JSON configuration
[
  {
    "label": "Article details",
    "state": "unfolded",
    "elements": [
      {
        "name": "shouldShowAuthor",
        "type": "checkbox",
        "label": "Show author of the entry",
        "defaultValue": 0
      }
    ]
  }
]

JSON translations

JSON translations
{
  "module": {
    "pl_PL": {
      "author": "autor"
    },
    "en_US": {
      "author": "author"
    }
  },
  "schema": {
    "pl_PL": {
      "Article details": "Szczegóły artykułu",
      "Show author of the entry": "Pokaż autora wpisu"
    },
    "en_US": {
      "Article details": "Article details",
      "Show author of the entry": "Show author of the entry"
    }
  }
}