- Issue created by @mistergroove
- 🇧🇪Belgium tim-diels Belgium 🇧🇪
I'm happy to review any provided patches as feature requests.
I want to use mask field in a custom module. Which is very straightforward for a textfield as I just need to add a mask attribute as so.
$form['myelement'] [
'#type' => 'textfield',
'#title' => 'My custom field',
'#size' => 19,
'#maxlength' => 19,
'#attributes' => [
'placeholder' => '0000-0000-0000-0000',
]
'#mask' => [
'value' => '0000-0000-0000-000A',
'reverse' => false,
'selectonfocus' => false,
'clearifnotmatch' => false
];
This works beautifully for the preset patterns. However in my case I need a custom pattern 0000-0000-0000-000C where C is a digit from 0-9 or an X. Now I could add that into the presets and it would work just fine, however I want my field to work out of the box if mask field is present.
What would be great if I could add custom patterns in through either a hook (if the mask field module is enabled) or better still via the '#mask' attribute for example:
$form['myelement'] [
'#type' => 'textfield',
'#title' => 'My custom field',
'#size' => 19,
'#maxlength' => 19,
'#attributes' => [
'placeholder' => '0000-0000-0000-0000',
]
'#mask' => [
'value' => '0000-0000-0000-000A',
'reverse' => false,
'selectonfocus' => false,
'clearifnotmatch' => false,
'custompatterns' => [
'C' => [
'pattern' => '[0-9X]',
]
]
];
i'm aware i could add my own pattern via install but that seems a messy way to do it.
Active
2.0
Code
I'm happy to review any provided patches as feature requests.