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
- libraries
- little_helpers ≥ 2.0-alpha6
- the cleave.js library.
Installation
Install this module and its dependencies like any other Drupal modules.
For installing the library:
- Go to https://github.com/nosir/cleave.js and download one of the releases.
- 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:
<span class="token variable">$form</span><span class="token punctuation">[</span><span class="token string">'numeral'</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span>
<span class="token string">'#type'</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'textfield'</span><span class="token punctuation">,</span>
<span class="token string">'#title'</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token function">t</span><span class="token punctuation">(</span><span class="token string">'Numeral'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token string">'#cleave'</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">[</span>
<span class="token string">'numeral'</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token constant">TRUE</span><span class="token punctuation">,</span>
<span class="token string">'numeralThousandsGroupStyle'</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token string">'thousand'</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>
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
- Project categories: Developer tools, Integrations
6 sites report using this module
- Created by torotil on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
