mage-os / module-advanced-widget
Advanced cms widget module
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
- This module let you specify Title separators inside widgets
[image: title section]
- 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]
- Row item images fields are available
[image: image field]
[image: image field selection]
- Row item select fields are available
[image: select field]
- Row item product fields are available
[image: product field]
[image: product field selection]
- Row item wysiwyg and colorpicker fields are also available (see the field reference below)
π Field reference
Two kinds of fields exist:
- Widget parameter fields β declared in your module's
etc/widget.xmlasxsi:type="block"parameters pointing at a renderer class fromMageOS\AdvancedWidget\Block\WidgetField\*. On the frontend the value arrives as plain block data ($block->getData('name')). - Repeatable row fields β declared in PHP inside a
Rowssubclass; 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:
textandtextareaare built in;select,image,product,wysiwygandcolorpickerare registered as custom field types inetc/adminhtml/di.xml(thecustomFieldsargument ofBlock\Adminhtml\Renderer\Repeatable). Third-party modules can register additional types through the same DI argument β each entry pairs atypename with a JS component and a.phtmlpartial.product: the field key must start withproductβ the admin renderer then auto-populates the sibling display keys<field>_sku,<field>_nameand<field>_imagefor the row list. On the frontend, load the product from the stored ID;ViewModel\ProductData::getProductById()does this and pre-resolvesmageos_main_image,mageos_swatch_image,mageos_small_imageandmageos_thumb_imageURLs 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
-
Install it into your Mage-OS/Magento 2 project with composer:
composer require mage-os/module-advanced-widget -
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.4
Added
- Colorpicker repeatable field: configurable starting color via a
defaultrow config key ('default' => '#RRGGBB'or anrgba(...)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,urldecodeand 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') === falseusages withstr_starts_with/str_contains - Add
declare(strict_types=1)and missing return type hints toController/Adminhtml/Image/Chooser - Clean up redundant
$this->escaper = $escaper ?: ObjectManager::getInstance()->get(...)fallback inController/Adminhtml/Product/Widget/Chooser(constructor already enforces non-null Escaper)
Changed
- Change remaining
privatepromoted/regular properties toprotectedfor 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!
| 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.
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.
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.
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
| 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
| 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.
More from mage-os
View vendorGCP event sinks for mage-os/mageos-async-events
Combine the power of LLM and domain knowledge to improve admin experience though a chatbot UI.
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.