# Datus

Extra powerful form schema.

# Usage

example:
  control:
    label: Example label
    type: text

    # HTML attributes
    attributes:
      placeholder: Example placeholder

    # Custom input-based options
    options: [ ]

  # Data validations
  validations: [ ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# Controls

Here is a complete list of control types:

  • checkbox
  • checkboxlist
  • date
  • datetime
  • email
  • float
  • hidden
  • integer
  • numeric
  • password
  • radiolist
  • select
  • strongpassword
  • submit
  • textarea
  • text
  • time
  • url

# Basic

Attributes

  • placeholder (string)
  • readonly (boolean)
  • disabled (boolean)

# Button

example:
  control:
    label: Example label
    type: button
1
2
3
4

# Checkbox

example:
  control:
    label: Example label
    type: checkbox
1
2
3
4

# CheckboxList

example:
  control:
    label: Example label
    type: checkboxlist
    options:
      items: [ user, admin ]
      useKeys: true | false
1
2
3
4
5
6
7
  • useKeys: false => values are user, admin
  • useKeys: true => values are 0, 1

# Date

example:
  control:
    label: Example label
    type: date
  options:
    shortcuts:
      - { title: 'Tomorrow', date: '+1 day' }
1
2
3
4
5
6
7

# DateTime

example:
  control:
    label: Example label
    type: datetime
  options:
    shortcuts:
      - { title: 'Tomorrow', date: '+1 day' }
1
2
3
4
5
6
7

# Email

example:
  control:
    label: Example label
    type: email
1
2
3
4

# Float

example:
  control:
    label: Example label
    type: float
1
2
3
4

# Hidden

example:
  control:
    label: Example label
    type: hidden
1
2
3
4

# Integer

example:
  control:
    label: Example label
    type: integer
1
2
3
4

# Numeric

example:
  control:
    label: Example label
    type: numeric
1
2
3
4

# Password

example:
  control:
    label: Example label
    type: password
1
2
3
4

# RadioList

example:
  control:
    label: Example label
    type: radiolist
    options:
      items: [ user, admin ]
      useKeys: true | false
1
2
3
4
5
6
7
  • useKeys: false => values are user, admin
  • useKeys: true => values are 0, 1

# Select

example:
  control:
    label: Example label
    type: select
    options:
      items: [ user, admin ]
      useKeys: true | false
1
2
3
4
5
6
7
  • useKeys: false => values are user, admin
  • useKeys: true => values are 0, 1

# StrongPassword

example:
  control:
    label: Example label
    type: strongpassword
1
2
3
4

# Submit

example:
  control:
    label: Example label
    type: submit
1
2
3
4

# Textarea

example:
  control:
    label: Example label
    type: textarea
1
2
3
4

# Text

example:
  control:
    label: Example label
    type: text
1
2
3
4

# Time

example:
  control:
    label: Example label
    type: time
1
2
3
4

# Url

example:
  control:
    label: Example label
    type: url
1
2
3
4

# Validations

The symfony/validator is used for performing validation. Take a look at the offical documentation (opens new window).

Here is a complete list of supported validators:

symfony/validator

  • blank
  • currency
  • date
  • datetime
  • email
  • equalTo
  • file
  • greaterThan
  • greaterThanOrEqual
  • iban
  • identicalTo
  • image
  • ip
  • isbn
  • language
  • length
  • lessThan
  • lessThanOrEqual
  • locale
  • notBlank
  • notNull
  • range
  • regex
  • time
  • url
  • uuid

datus

  • dateTimeGreaterThan
  • dateTimeRelative

# Regex

You can use symfony regex validator with PCRE syntax support.

validations:
  regex:
    pattern: "#^[0-9]+$#"
    message: "Please fill only numeric value"
1
2
3
4

Be carefull with range expressions like {2,4}. Whole pattern is processed as Latte expression, so you have to use alternative {l} and {r} placeholders.

validations:
  regex:
    pattern: "#^[0-9]{2,4}$#"       # not working
    pattern: "#^[0-9]{l}2,4{r}}$#"  # working
1
2
3
4

# Basic

Required

By default are inputs optional. You can change it by validation required.

example:
  control: { ... }
  validations:
    required: true
1
2
3
4

# NotBlank

example:
  control: { ... }
  validations:
    notBlank: [ message: "Subject must be filled" ]
1
2
3
4

# DateTimeGreaterThan

example:
  control: { ... }
  validations:
    dateTimeGreaterThan: [ message: "Term must be in the future", compareTo: "NOW" ]
    dateTimeGreaterThan: [ message: "Term must be in the next month", compareTo: "first day of next month ]
1
2
3
4
5

# DateTimeRelative

example:
  control: { ... }
  validations:
    dateTimeRelative: [ ]
    dateTimeRelative: [ message: "Invoice expiration is not valid relative format" ]
1
2
3
4
5