This is a Drupal module that integrates the cleave.js input field auto-formatter with the Drupal form-API.

This is pure API module without any UI. You only need to install it, when anoher module depends on it.

Dependencies

Installation

Install this module and its dependencies like any other Drupal modules.

For installing the library:

  1. Go to https://github.com/nosir/cleave.js and download one of the releases.
  2. Put it in a libraries-folder as described in the libraries documentation. Make sure the folder is named cleave.js.

Usage

When you add #cleave-property to any of your form-API elements Cleave will be invoked automatically on the resulting HTML element using this config.

Example:

$form['numeral'] = [
  '#type' => 'textfield',
  '#title' => t('Numeral'),
  '#cleave' => [
    'numeral' => TRUE,
    'numeralThousandsGroupStyle' => 'thousand',
  ],
];

Devlopment

Development on this module is happening mainly on github. Feel free to post issues and pull requests there.

Note: Development branches on drupal.org might be outdated because they are only pushed to in order to tag releases.

Supporting organizations: 
Development of this module

Project information

Releases