Skip to content

Number

Number element is an input with number type.

number

Options

prefix

string Optional parameter.

postfix

string Optional parameter.

placeholder

string Optional parameter. Placeholder in input.

JSON
{
"options":
    {
      "prefix" : "-",
      "postfix" : "%",
      "placeholder" : "discount"
    }
}

Build-in Validators

Element have build-in one validator: float.

Available Validators

Element has available validators:

Relations Support

Element supports relations between elements.

Configuration output schema

schema
{
  "<element_type>" : "number",
  "<element_name>" : string,
  "<element_label>" : string,
  "<element_labelDescription>" : string,
  "<element_isRequired>" : bool,
  "<element_isHidden>" : bool,
  "<element_defaultValue>" : number,
  "<element_options>" : {
    "<element_option_prefix>" : string,
    "<element_option_postfix>" : string,
    "<element_option_placeholder>" : string
  },
  "<element_validators>" : []
}
example
{
  "type" : "number",
  "name" : "discount",
  "label" : "Discount on sign to newsletter",
  "labelDescription" : "When user sign to newsletter will get X percentage discount.",
  "isRequired" : false,
  "isHidden" : false,
  "defaultValue" : 2,
  "validators": [
    { "type" : "positiveNumber" },
    { "type" : "int" },
    { "type" : "lessEqThan", "options" : { "max" : 25 } }
  ],
  "options": {
    "prefix" : "-",
    "postfix" : "%",
    "placeholder" : "discount"
  }
}

Element value

If value is filled: number (int or float, depending on the applied validators).

usage in module TWIG
{% if moduleConfig.discount %}
    <p>{{ translate("Discount") }}: {{ moduleConfig.discount }}%</p>
{% endif %}

Example of module

Twig

Twig
{% if moduleConfig.discount %}
    <p>{{ translate("Sign up for the newsletter and get a discount") }}: {{ moduleConfig.discount }}%</p>
{% endif %}

JSON configuration

JSON configuration
[
  {
    "label": "Newsletter",
    "state": "unfolded",
    "elements": [
      {
        "type": "number",
        "name": "discount",
        "label": "Discount on sign to newsletter",
        "labelDescription": "When user sign to newsletter will get X percentage discount.",
        "defaultValue": 2,
        "validators": [
          { "type": "positiveNumber" },
          { "type": "int" },
          { "type": "lessEqThan", "options": { "max": 25 } }
        ],
        "options": {
          "prefix": "-",
          "postfix": "%",
          "placeholder": "discount"
        }
      }
    ]
  }
]

JSON translations

JSON translations
{
  "module": {
    "pl_PL": {
      "Sign up for the newsletter and get a discount": "Zapisz się do newslettera i zyskaj rabat"
    },
    "en_US": {
      "Sign up for the newsletter and get a discount": "Sign up for the newsletter and get a discount"
    }
  },
  "schema": {
    "pl_PL": {
      "Newsletter": "Newsletter",
      "Discount on sign to newsletter": "Rabat za zapis do newslettera",
      "When user sign to newsletter will get X percentage discount.": "Po zapisaniu się do newslettera użytkownik otrzyma X procent rabatu."
    },
    "en_US": {
      "Newsletter": "Newsletter",
      "Discount on sign to newsletter": "Discount on sign to newsletter",
      "When user sign to newsletter will get X percentage discount.": "When user sign to newsletter will get X percentage discount."
    }
  }
}