mage-os / module-advanced-widget

mage-os/module-advanced-widget

Advanced cms widget module

  • Davide Lunardon
  • Yuriy Boyko
magento2-module Compatibility: 2.4.7-2.4.9 Code Quality: Fail Tests: N/A Security: Pass MIT

Are you the maintainer of mage-os?

Packagento pulls mage-os's Composer packages from the public registry so buyers can find them here.

Claim the namespace to take ownership, publish new releases directly, and start charging for premium versions.

Claim this namespace β†’

MageOS AdvancedWidget Module for Magento

Add configurable multi-row CMS Widgets with image picker component, product picker component, select fields and much more.


Overview

The AdvancedWidget module allows you to define multi-row CMS widgets.
These features combined with MageOS_PageBuilderWidget module (that is explicit dependency) make finally possible to develop custom pagebuilder components with own preview and a large set of configurations.
Complex pagebuilder ui components development is no more needed.

πŸš€ Features

  1. This module let you specify Title separators inside widgets
    [image: title section]
  1. This module let you specify multiple "repeatable" sections where you can specify unlimited rows inside widgets
    [image: repeatable section]

2.1) Each item field can receive a dedicated tooltip
[image: repeatable section]

2.2) Each field is validated and ask to be required for compilation
[image: repeatable section]

2.3) Items can be sorted
[image: repeatable section]

2.4) You can specify whether a field is editable directly in the main box or whether it must be edited in the detail modal.
[image: repeatable section]

  1. Row item images fields are available
    [image: image field]
    [image: image field selection]
  1. Row item select fields are available
    [image: select field]
  1. Row item product fields are available
    [image: product field]
    [image: product field selection]
  1. Row item wysiwyg and colorpicker fields are also available (see the field reference below)

πŸ“– Field reference

Two kinds of fields exist:

  1. Widget parameter fields β€” declared in your module's etc/widget.xml as xsi:type="block" parameters pointing at a renderer class from MageOS\AdvancedWidget\Block\WidgetField\*. On the frontend the value arrives as plain block data ($block->getData('name')).
  2. Repeatable row fields β€” declared in PHP inside a Rows subclass; editors can add, sort and delete unlimited rows, each row containing these fields.

Widget parameter fields

Image β€” Block\WidgetField\Image

Renders a text input with a "Choose Image..." button that opens the Magento media gallery browser. Stores the media-relative path (e.g. wysiwyg/hero/image.jpg) as a plain string.

<parameter name="image" sort_order="10" required="true" visible="true" xsi:type="block">
    <label translate="true">Image</label>
    <block class="MageOS\AdvancedWidget\Block\WidgetField\Image">
        <data>
            <item name="button" xsi:type="array">
                <item name="open" xsi:type="string">Choose image...</item>
            </item>
        </data>
    </block>
</parameter>

On the frontend, resolve the stored path with $block->getImageUrl('image') (from Block\Widgets\AbstractColumns) β€” it prefixes the store media base URL when the value isn't already absolute.

TextArea β€” Block\WidgetField\TextArea

Plain multi-line text input (no HTML editor). Line breaks are preserved in the stored value.

<parameter name="description" sort_order="20" required="false" visible="true" xsi:type="block">
    <label translate="true">Description</label>
    <block class="MageOS\AdvancedWidget\Block\WidgetField\TextArea"/>
</parameter>

WYSIWYG β€” Block\WidgetField\Wysiwyg

Full TinyMCE editor (variables and images enabled, nested widgets disabled). The stored value is HTML β€” don't escapeHtml it on the frontend; sanitize it instead, e.g. with Block\Widgets\Template::stripTags(), which ships with a sensible default tag whitelist.

<parameter name="content" sort_order="30" required="false" visible="true" xsi:type="block">
    <label translate="true">Rich content</label>
    <block class="MageOS\AdvancedWidget\Block\WidgetField\Wysiwyg"/>
</parameter>

Title separator β€” Block\WidgetField\Title

Purely visual: renders a heading/divider inside the widget form to group fields. It stores no meaningful value β€” the displayed text comes from the parameter's <description>. Don't read this parameter on the frontend.

<parameter name="section_title" sort_order="40" required="false" visible="true" xsi:type="block">
    <label translate="true"> </label>
    <description translate="true"><![CDATA[<h2>Content</h2><hr/>]]></description>
    <block class="MageOS\AdvancedWidget\Block\WidgetField\Title"/>
</parameter>

Repeatable rows β€” Block\WidgetField\Rows

The headline feature: unlimited sortable rows, each with its own field set. The parameter name must start with repeatable_ β€” both the save plugin (Plugin\SaveRepeatableItems) and the admin renderer detect repeatable values by that prefix. A widget can have several repeatable parameters, each with its own Rows subclass.

<parameter name="repeatable_items" xsi:type="block" sort_order="50" required="false" visible="true">
    <label translate="true">Items</label>
    <block class="Vendor\Module\Block\Widget\Repeatable\CardItem"/>
</parameter>

Repeatable row fields

Extend MageOS\AdvancedWidget\Block\WidgetField\Rows and fill the $rows property β€” an ordered map of field_key => config:

class CardItem extends \MageOS\AdvancedWidget\Block\WidgetField\Rows
{
    protected $rows = [
        'title' => [
            'label' => 'Title',
            'type' => 'text',
            'required' => true,
            'preview' => true,
        ],
        'image' => [
            'label' => 'Image',
            'type' => 'image',
            'preview' => true,
        ],
        'style' => [
            'label' => 'Card style',
            'type' => 'select',
            'options' => [
                'light' => 'Light',
                'dark' => 'Dark',
            ],
            'preview' => false,
        ],
        'background' => [
            'label' => 'Background color',
            'type' => 'colorpicker',
            'default' => '#1E88E5',
            'description' => 'Shown as a tooltip next to the field.',
            'preview' => false,
        ],
    ];
}

Row config keys

Key Meaning
label Admin label for the field
type One of the row field types below
required Adds admin-side validation on the row
preview true β†’ editable directly in the collapsed row list; false β†’ only in the row's edit modal
description Tooltip text next to the field
options value => label map, select type only
default Starting color for a colorpicker field, e.g. #FF0000 or rgba(0,0,0,1); falls back to #FFFFFF

Row field types

Type Admin control Stored value
text Single-line text input Plain string
textarea Multi-line text input Plain string, line breaks preserved
select Dropdown built from the options map The selected option value
image Media gallery browser button Media-relative path (resolve with getImageUrlByPath())
product Product chooser grid Product ID β€” see below
wysiwyg TinyMCE editor in the row modal HTML string (same escaping caveats as the WYSIWYG parameter)
colorpicker JSColor picker (rgba format); starting color set via the row's default key CSS color string, e.g. rgba(255,255,255,1)

Notes:

  • text and textarea are built in; select, image, product, wysiwyg and colorpicker are registered as custom field types in etc/adminhtml/di.xml (the customFields argument of Block\Adminhtml\Renderer\Repeatable). Third-party modules can register additional types through the same DI argument β€” each entry pairs a type name with a JS component and a .phtml partial.
  • product: the field key must start with product β€” the admin renderer then auto-populates the sibling display keys <field>_sku, <field>_name and <field>_image for the row list. On the frontend, load the product from the stored ID; ViewModel\ProductData::getProductById() does this and pre-resolves mageos_main_image, mageos_swatch_image, mageos_small_image and mageos_thumb_image URLs on the product.

Reading values on the frontend

Extend MageOS\AdvancedWidget\Block\Widgets\AbstractColumns in your widget block:

foreach ($this->getRepeatableField('repeatable_items') as $item) {
    $title = $item['title'] ?? '';
    $image = $this->getImageUrlByPath($item['image'] ?? '');
    // ...
}

Available helpers:

Method Purpose
getRepeatableField($name) Decoded array of row arrays for a repeatable parameter
getRepeatableFieldAsObject($name) Same rows as DataObjects ($item->getTitle())
getImageUrl($field) / getImageUrlByPath($path) Resolve a stored media-relative path into a full media URL
getPreparedUrl($url) Normalize relative link values against the store base URL
getPreparedDescription($field) Replace \EOL markers with <br />

πŸ”§ Installation

  1. Install it into your Mage-OS/Magento 2 project with composer:

    composer require mage-os/module-advanced-widget
    
  2. Enable module

    bin/magento module:enable MageOS_AdvancedWidget
    bin/magento setup:upgrade
    

🀝 Changelog

Please see CHANGELOG for more information on what has changed recently.

πŸ“„ License

The MIT License (MIT). Please see License File for more information.

Attribution

This software uses Open Source software. See the ATTRIBUTION page for these projects.

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.

1.2.5

Fixed

  • adminhtml css

1.2.4

Added

  • Colorpicker repeatable field: configurable starting color via a default row config key ('default' => '#RRGGBB' or an rgba(...) value). When omitted it still falls back to #FFFFFF.

Fixed

  • sync correctly colorpicker values sync between preview and modal
  • wysiwyg field now shows a limited number of elements on the toolbar

1.2.3

Fixed

  • Remove debugging code

1.2.2

Fixed

  • Change declaration for properties

1.2.1

Fixed - Added

  • Add wysiwyg and color repeatable component types
  • Fix fatal error on redeclaration for properties removing protected attribute from $rawResultFactory and $getInsertImageConten. Thanks to @Sental

1.2.0 - 2026-04-21

Fixed

  • PHP 8.5 compatibility: cast nullable values to string before passing to str_replace, strpos, str_contains, preg_match, explode, urldecode and similar string functions to avoid deprecation notices and fatal errors
  • Cast nullable values to string/int before using as array index (PHP 8.5 null array key deprecation)
  • Replace deprecated strpos / strpos(..., 'http') === false usages with str_starts_with / str_contains
  • Add declare(strict_types=1) and missing return type hints to Controller/Adminhtml/Image/Chooser
  • Clean up redundant $this->escaper = $escaper ?: ObjectManager::getInstance()->get(...) fallback in Controller/Adminhtml/Product/Widget/Chooser (constructor already enforces non-null Escaper)

Changed

  • Change remaining private promoted/regular properties to protected for consistent extensibility across all classes

1.1.2

Fixed

  • Fix getRowClickCallback() returning null instead of string when massaction is enabled
  • Change private constructor properties to protected for extensibility

1.1.1

Fixed

  • Unset missing products from repeatable fields during widget configuration rendering

1.1.0

Updated

  • Update composer JSON making the module installable for Magento Opensource also

1.0.0

Added

  • First Commit, now is possible to define CMS widgets with multiple row fields!
Versions
Version Stability QA Status Compatibility Released
1.2.5 stable Fail Magento 2.4.7-2.4.9 Details 2026-07-28 02:39:40
1.2.4 stable Fail Magento 2.4.7-2.4.9 Details 2026-07-22 12:48:10
1.2.3 stable Fail Magento 2.4.7-2.4.9 Details 2026-06-26 12:30:24
1.2.2 stable Fail Magento 2.4.7-2.4.9 Details 2026-05-30 16:32:10
1.2.1 stable Not tested Not yet tested Details 2026-05-29 13:13:18
1.2.0 stable Not tested Not yet tested Details 2026-05-06 03:30:45
1.1.2 stable Not tested Not yet tested Details 2026-04-16 16:14:09
1.1.1 stable Not tested Not yet tested Details 2026-03-13 07:06:07
1.1.0 stable Not tested Not yet tested Details 2026-03-10 10:44:00
1.0.1 stable Not tested Not yet tested Details 2026-02-25 09:45:11
1.0.0 stable Not tested Not yet tested Details 2025-10-11 17:29:36

Requires 4

Package Constraint
mage-os/module-page-builder-widget *
magento/module-page-builder ^2.0
magento/module-widget *
php ^8.1

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 Fail 139 46 errors, 93 warnings (ruleset: Magento2), 45 auto-fixable with phpcbf
PHPMD Warning 2 2 rule violations (UnusedPrivateField:2)
Cpd Pass 0
Composer validate Info 2 valid; 2 advisory notes (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.

PHPStan results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 19 19
2.4.8 18 18
2.4.9 14 14

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
MIT
Authors

More from mage-os

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.