/redaxo-mform:mform-flex-repeaterfrom redaxo-mform
Creates dynamic list/repeater fields in REDAXO modules with MForm. Covers addFlexRepeaterElement(), addRepeaterElement(), nested repeaters, supported widget types, __MFRID__ placeholder, and reading values in OUTPUT PHP.
Ships in redaxo-mform. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Written for MForm ≥ 9.0.0 (the version this plugin requires). Items marked (v9+) do not exist in MForm 8.x. Runtime check:
rex_version::compare(rex_addon::get('mform')->getVersion(), '9.0.0', '>=').
The Flex Repeater lets editors add, remove and reorder an arbitrary number of rows without Alpine.js (v9+; MForm 8.x only has the Alpine.js-based addRepeaterElement()). Data is stored as JSON in a single REX_VALUE[n] slot.
use FriendsOfRedaxo\MForm;
$mform = MForm::factory();
$mform->addFlexRepeaterElement(1,
MForm::factory()
->addTextField('title', ['label' => 'Titel'])
->addTextAreaField('text', ['label' => 'Text'])
->addMediaField('image', ['label' => 'Bild', 'preview' => 1])
,
[
'btn_text' => 'Eintrag hinzufügen',
'btn_class' => 'btn-default',
'open' => true, // rows expanded by default
'confirm_delete' => true,
'min' => 0,
'default_count' => 1, // pre-fill 1 empty row on first render
]
);
echo $mform->show();
Alias:
addRepeaterElement()callsaddFlexRepeaterElement()internally. Both are equivalent (MForm 9).
The outer repeater itself uses an integer slot ID (1, 2, … = REX_VALUE[1]).
The fields inside the sub-form use plain string keys – they become array keys in the JSON of each row.
$mform->addFlexRepeaterElement(1, // outer slot → REX_VALUE[1]
MForm::factory()
->addTextField('headline', ['label' => 'Überschrift']) // → $row['headline']
->addCustomLinkField('link', ['label' => 'Link']) // → $row['link']
);
No dotted prefix and no row index is needed in the template – the repeater handles row indices automatically at runtime.
For widget-internal IDs that must be unique per row (e.g. TinyMCE, modal IDs), use __MFRID__ in HTML attributes (not in the field ID itself):
->addModalElement(
'Einstellungen',
MForm::factory()->addTextField('cssClass', ['label' => 'CSS-Klasse']),
'btn-default', 'left',
['id' => 'modal-__MFRID__']
)
The repeater replaces __MFRID__ with a unique integer for each row.
All standard MForm field types work. Special widgets explicitly supported:
| Widget method | Notes |
|---|---|
addCustomLinkField() | Single custom link (intern/extern/media/mailto/tel) |
addCustomLinkMultipleField() | Multiple links as JSON array (v9+) |
addMFormLinkField() | Internal-link-focused custom link (v9+) |
addMediaField() / addMFormMediaField() | Single media file from mediapool (addMFormMediaField(): v9+) |
addMedialistField() | Multiple media files list |
addImagelistField() | Image gallery with view-toggle (grid/list) |
addLinklistField() | Multiple internal article links |
addColorSwatchField() | Color / CSS-class picker (v9+) |
addRadioField() | Standard radio group |
addCheckboxField() | Checkbox with Bootstrap wrapper |
addCheckboxGroupField() | Multi-checkbox storing comma-separated string (v9+) |
addRadioImgField() | Visual layout picker |
addTextReadOnlyField() | Read-only text display |
addTextAreaReadOnlyField() | Read-only textarea display |
addHeadline() | Static headline inside the row template |
addDescription() | Static hint text inside the row template |
addModalElement() | Sub-form in a Bootstrap modal; uses __MFRID__ (v9+) |
addCollapseElement() | Collapsible section inside a row |
addTextAreaField() with TinyMCE | Rich text editor; unique instance ID per row via __MFRID__ |
| MarkdownEditor | Markdown editor; unique instance ID per row via __MFRID__ |
A repeater can contain another repeater one level deep. The inner sub-key is just a plain string – in the outer row's JSON it becomes an array under that key.
// Inner sub-form
$stepForm = MForm::factory()
->addTextField('title', ['label' => 'Schritt-Titel'])
->addTextAreaField('body', ['label' => 'Inhalt']);
// Outer sub-form embeds the inner one under sub-key 'steps'
$sectionForm = MForm::factory()
->addTextField('section_title', ['label' => 'Abschnittstitel'])
->addRepeaterElement('steps', $stepForm, true, true, [
'btn_text' => 'Schritt hinzufügen',
]);
$mform->addRepeaterElement(2, $sectionForm, true, true, [
'btn_text' => 'Abschnitt hinzufügen',
]);
In OUTPUT each section row contains $section['steps'] as a normal array of step rows.
Use MFormRepeaterHelper::decode() – it handles JSON decoding, HTML entity decoding and filters disabled rows in one step.
use FriendsOfRedaxo\MForm\Repeater\MFormRepeaterHelper;
$items = MFormRepeaterHelper::decode('REX_VALUE[2]');
foreach ($items as $item) {
echo rex_escape($item['title'] ?? '');
}
use FriendsOfRedaxo\MForm\Repeater\MFormRepeaterHelper;
$items = MFormRepeaterHelper::decode('REX_VALUE[1]');
// Filter by field value
$news = MFormRepeaterHelper::filterByField($items, 'category', 'news');
// Strict comparison (===)
$active = MFormRepeaterHelper::filterByField($items, 'status', '1', strict: true);
// Sort (asc / desc, auto-detects numeric vs. alphabetic)
$sorted = MFormRepeaterHelper::sortByField($items, 'date', 'desc');
// Group → [groupname => [items]]
$grouped = MFormRepeaterHelper::groupByField($items, 'category');
// Pagination
$limit = 10;
$page = 0; // current page, 0-based
$paged = MFormRepeaterHelper::limitItems($items, limit: $limit, offset: $page * $limit);
use FriendsOfRedaxo\MForm\Utils\MFormOutputHelper;
$items = MFormRepeaterHelper::decode('REX_VALUE[2]');
foreach ($items as $item) {
$url = MFormOutputHelper::getCustomUrl($item['link'] ?? '');
$data = MFormOutputHelper::prepareCustomLink(['link' => $item['link'] ?? ''], true);
if ($url) {
echo '<a href="' . rex_escape($url) . '"' . $data['customlink_target'] . '>'
. rex_escape($data['customlink_text'])
. '</a>';
}
}
decode() vs prepareItemsForOutput()| Method | When to use |
|---|---|
decode(string $rexValue) | Recommended – use directly in module OUTPUT |
prepareItemsForOutput(array $items) | When the array is already decoded (e.g. from a DB query) |
Medialist and Imagelist store a comma-separated filename string:
$mediaNames = array_filter(explode(',', $item['images'] ?? ''));
foreach ($mediaNames as $filename) {
$media = rex_media::get($filename);
if ($media) {
echo '<img src="' . rex_url::media($filename) . '" alt="' . rex_escape($media->getTitle()) . '">';
}
}
Or use FriendsOfRedaxo\MForm\Output\MFormOutput::mediaList($item['images'] ?? '') – it splits the value and returns only the rex_media objects that exist.
| Option key | Type | Default | Description |
|---|---|---|---|
btn_text | string | 'Hinzufügen' | Label on the "add row" button |
btn_class | string | 'btn-default' | Bootstrap class for the add button |
open | bool | true | Rows expanded by default |
confirm_delete | bool | true | Show confirmation dialog before deleting a row |
min | int | 0 | Minimum number of rows (rows below this cannot be deleted) |
default_count | int | 0 | Number of empty rows to pre-fill on first render (v9+) |
sortable | bool | true | Allow drag-and-drop reordering |
0 as the row-index placeholder in IDs, not the actual index. The repeater renders the template once and patches all IDs at JS runtime.__MFRID__ is a string placeholder – only use it inside attributes (e.g. id, data-*), not as the field value ID.MFormRepeaterHelper::decode(), not json_decode() directly – the helper handles entity decoding and filters disabled rows automatically.__MFRID__ in the editor's ID attribute to ensure uniqueness per row (e.g. ['id' => 'tinymce-__MFRID__']).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
5 skills in this plugin
/mform-basicsBuilding REDAXO module inputs with MForm – MForm::factory(), all add*Field() methods (text, textarea, select, radio, checkbox, link, media, hidden, headline, description, alert, html), wrapper elements (fieldset, column, tab, collapse, accordion, modal, inline, conditional), setters (setLabel, setAttributes, setOptions, setSqlOptions, setTooltipInfo, setFull, setSize, setMultiple, setDefaultValue), and how the form is rendered via show(). Use when the user writes or edits module INPUT PHP, uses MForm to build a backend form, or asks how to add a specific field type to a REDAXO module./mform-outputReading MForm field values in REDAXO module OUTPUT PHP – MFormOutputHelper::createLinkData(), normalizeLinkData(), normalizeRepeaterItems(), getCustomLinkUrl(), getCustomUrl(), prepareCustomLink(), decoding repeater JSON, working with customlink_url / customlink_text / customlink_target / customlink_class / type / article_id / metadata. Use when the user writes the OUTPUT section of a REDAXO module that uses MForm, processes link values, displays repeater rows, or needs to resolve redaxo:// URLs to actual hrefs./mform-widgetsAdvanced MForm widget fields – Custom-Link (addCustomLinkField, addCustomLinkMultipleField, addMFormLinkField), Media picker (addMediaField, addMFormMediaField), Medialist, Imagelist, Linklist, ColorSwatch (addColorSwatchField). Covers all data-* attributes for controlling which link types are enabled (intern/extern/media/mailto/tel), ylink table links, media type restrictions, preview options, and how each widget stores and returns its value. Use when the user adds a link picker, media picker, image gallery, link list, or color swatch to a REDAXO module or YForm form./mform-yformUsing MForm-provided YForm value types in YForm table definitions and YForm forms – custom_link, custom_link_multi, color_swatch, imagelist, medialist, linklist value types. Covers how to add these fields programmatically (rex_yform_manager_table_api::setTableField) and via tableset JSON, their stored value formats, how to read values via YOrm datasets, and ytemplates used for rendering in the backend. Use when the user adds a custom_link, color_swatch, imagelist, medialist, or linklist field to a YForm table, uses these field types in a YForm form, or asks how to render MForm widget values stored in a YForm database column.npx claudepluginhub friendsofredaxo/claude-marketplace --plugin redaxo-mformOther plugins' skills for the same job