Jump to content

InputfieldMatrixType - Type identifiers and structured data extraction


Recommended Posts

Posted

Hi,

A small but practical module for anyone working with ProFields Repeater Matrix on the frontend.

GitHub: https://github.com/mxmsmnv/InputfieldMatrixType

The problem

Repeater Matrix is great for building flexible content blocks — but when you need to identify item types programmatically, things get messy fast. Types are stored in internal template names like repeater_matrix_123, there's no clean way to get a human-readable type identifier, and extracting structured data from different item types means repetitive code in every template.

I ran into this building a gift catalog on e-commerce project — a matrix field with three item types: Box, Handbag, and Bouquet. Each has different fields and pricing. I needed clean type identifiers for frontend rendering and a JSON API for Alpine.js components.

What it does

  • FieldtypeMatrixType — a dedicated field for storing type identifiers per matrix item (e.g. box, handbag, bouquet)
  • InputfieldMatrixType — admin UI to configure identifier and display name per type
  • MatrixDataProcessor — PHP class that extracts all matrix item data into a consistent structured array, JSON-ready
$processor = new MatrixDataProcessor($page);
$items = $processor->getItems('opt');
echo json_encode($items);

Each item returns id, type, displayName, price, and a fields array with name/label/type/value — ready for Alpine.js, Vue, or any API endpoint.

Supports Text, Textarea, Options, Checkbox, Integer, Float, Page references, and Image fields out of the box. Custom field types via formatValue() override.

Requirements: ProcessWire 3.0+, PHP 8.1+, ProFields Repeater Matrix

MIT License.

  • Like 9

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...