loki / magento2-flatpickr

loki/magento2-flatpickr

Magento 2 module to add an Alpine.js directive x-flatpickr

magento2-module Compatibility: 2.4.7-2.4.9 Code Quality: Fail Tests: N/A Security: Pass OSL-3.0

Loki_Flatpickr

This Magento 2 module adds an Alpine.js x-flatpickr directive to transform a simple input field into a Flatpickr date picker.

Installation

composer require loki/magento2-flatpickr
bin/magento module:enable Loki_Flatpickr

Usage

To add Flatpickr to a custom HTML input, just add the x-flatpickr directive to your HTML element:

<input type="date" x-flatpickr/>

If you want to add Flatpickr to a Loki Field Component, add the x-flatpickr directive via the XML layout:

<block name="example" template="Loki_FieldComponents::form/field.phtml">
    <arguments>
        <argument name="input_type" xsi:type="string">date</argument>
        <argument name="field_attributes" xsi:type="array">
            <item name="x-flatpickr" xsi:type="boolean">true</item>
        </argument>
    </arguments>
</block>

Customization

The Flatpickr directive is inserted via a block loki.directives.flatpickr. If you want to change the options for Flatpickr, you can use the block argument options for this:

<referenceBlock name="loki.directives.flatpickr">
    <arguments>
        <argument name="options" xsi:type="array">
            <item name="altFormat" xsi:type="string">d-m-Y</item>
        </argument>
    </arguments>
</referenceBlock>

Instead of a global configuration, options can also be set per field:

<block name="example" template="Loki_FieldComponents::form/field.phtml">
    <arguments>
        <argument name="input_type" xsi:type="string">date</argument>
        <argument name="field_attributes" xsi:type="array">
            <item name="x-flatpickr" xsi:type="array">
                <item name="altFormat" xsi:type="string">d-m-Y</item>
            </item>
        </argument>
    </arguments>
</block>

For all options, see https://flatpickr.js.org/options/

Note that changing the dateFormat will also change the value sent to Magento. It is probably best to keep this at its default (Y-m-d).

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.

[Unreleased]

[1.0.8] - 19 May 2026

Fixed

  • Do not preload Flatpickr CSS

[1.0.7] - 08 April 2026

Fixed

  • Properly set first day of week
  • Allow setting options per field

[1.0.6] - 23 January 2026

Fixed

  • Increase PHPCS_LEVEL to 6
  • Add new GitHub Action workflows

[1.0.5] - 12 December 2025

Fixed

  • Do not defer CSS
  • Update composer keywords
  • Update composer keywords
  • Update composer keywords

[1.0.4] - 23 September 2025

Fixed

  • Rename loki.script from container to block to allow caching
  • Rename loki script containers

[1.0.3] - 04 September 2025

Fixed

  • Loading Flatpickr JS async does not work
  • Remove redundant field_type definition from README

[1.0.2] - 03 September 2025

Fixed

  • array_merge_recursive does not work, use array_merge instead
  • Add examples to README

[1.0.1] - 02 September 2025

Fixed

  • Optimize loading of remote resources
  • Allow configuring options from XML layout
  • Add additional handle loki_flatpickr for usage outside of Loki Components

[1.0.0] - 31 August 2025

Added

  • Initial release
Versions
Version Stability QA Status Compatibility Released
1.0.8 stable Fail Magento 2.4.7-2.4.9 Details 2026-05-19 13:35:02
1.0.7 stable Not tested Not yet tested Details 2026-04-08 13:56:52
1.0.6 stable Not tested Not yet tested Details 2026-01-23 18:41:32
1.0.5 stable Not tested Not yet tested Details 2025-12-12 09:35:59
1.0.4 stable Not tested Not yet tested Details 2025-09-23 14:39:30
1.0.3 stable Not tested Not yet tested Details 2025-09-04 08:25:09
1.0.2 stable Not tested Not yet tested Details 2025-09-03 07:15:47
1.0.1 stable Not tested Not yet tested Details 2025-09-02 07:16:47
1.0.0 stable Not tested Not yet tested Details 2025-08-31 09:18:51

Requires 4

Package Constraint
ext-json *
loki/magento2-components ^2.2
magento/framework ^103.0
magento/module-store ^101.0

Compatibility

Each Magento release line is installed on its supported PHP versions, then the module is built (DI compilation + static-content deploy) and its unit and integration suites are run. The matrix shows the lines and PHP versions the module is confirmed to install and run on. Code-quality results further down (phpstan, phpcs, …) are reported separately and never affect compatibility.

Compatibility matrix (Magento × PHP)
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 Pass Pass
2.4.8 Pass Pass
2.4.9 Pass Pass

Code Quality

Advisory checks against the module's source. Static analysis runs once across the whole module; PHPStan re-runs per Magento + PHP version because resolvable symbols differ between releases. These NEVER affect the Compatibility badge — a phpcs finding can't make a module incompatible.

Static analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

Static analysis results
Tool Status Findings Summary
PHPCS Pass 0
PHPMD Pass 0
Cpd Pass 0
Composer validate Info 1 valid; 1 advisory note (composer validate --strict)

PHPStan

Type-checks the module's PHP against a real Magento install at the configured gate level. Re-runs per Magento and PHP version because resolvable symbols differ between releases. Cell → details modal.

PHPStan results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 9 9
2.4.8 9 9
2.4.9 8 8

Tests

Unit and integration suites, run for each applicable Magento and PHP version. A test failure speaks to the module's behaviour, not its compatibility with a Magento line, so it is reported here separately and never reddens the compatibility matrix.

Unit tests

Unit tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Integration tests

Integration tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Security

Security checks run directly against the module: an audit of its declared dependencies for known vulnerabilities (composer audit) and a scan of its source for malware and web-shell signatures. Each runs once. A malware detection fails the version outright.

Security results
Tool Status Findings Summary
Composer audit Pass 0
Malware scan Pass 0
License
OSL-3.0

More from Loki Extensions

View vendor
Make it pay

Turn an existing module into recurring revenue.

If you already maintain a Magento 2 module on GitHub or GitLab, listing it on Packagento takes about five minutes. We mirror your tags, handle distribution signing, and route paid licenses through Stripe Connect, so you can keep shipping the way you already do.